Hello everybody.
I have a strange problem (aren't they all
)
The challenge:
I have two files
#1 holds a simple list of 3000+ lines, each line beeing an order ID like for example 53267
This file is named ordreliste_2008.txt
#2 holds more than 33000 lines. Each line holds an information string like this
55072;;386;4;;175
the first 5 digits are the order ID.
This file is named ordrelinje.csv
I want to run a while loop iterating file #1 and grep the order ID in file #2.
The result will eventually be >> into a new file
I'm using this simple while loop
while read LINE
do
echo "this is LINE: $LINE" #simple check to see the value of the line
grep "$LINE" ordrelinje.csv
echo $? #simple check to see the result of last command
done < /home/noricom_bergen/ordreliste_2008.txt
My result is all negative - no output
I have tried to write '$LINE', $LINE - same result
If I do this:
while read LINE
do
echo "this is LINE: $LINE" #simple check to see the value of the line
grep
55072 ordrelinje.csv
echo $? #simple check to see the result of last command
done < /home/noricom_bergen/ordreliste_2008.txt
I get an output
The same happens if I put in
while read LINE
do
echo "this is LINE: $LINE" #simple check to see the value of the line
test=52072
grep $test ordrelinje.csv
echo $? #simple check to see the result of last command
done < /home/noricom_bergen/ordreliste_2008.txt
If I however put in test=$LINE the output is nothing
It is only when I use the variable $LINE together with grep that I get this peculiar error.
My conclution is that the grep itself is working ok - I've proved that, but there is a catch with the variable $LINE.
Anyone out there who can help me out?