While loop
by Drosera_capensis from LinuxQuestions.org on (#4VA9S)
Hello everyone,
I am not familiar with while loops, and meet some difficulties with my first script using one.
I try to print all the rows in the first column of a file matching a list of names.
the syntax of the script is:
Code:cat list | while read f;
do
awk '{ if ($1 == "$f" ) { print } }' file ;
doneI have tested the awk command alone, and the loop itself with another command (echo $f), and it is working fine.
But for some reason, the while loop with the command awk is not working.
Would you have any idea what could be the error here?


I am not familiar with while loops, and meet some difficulties with my first script using one.
I try to print all the rows in the first column of a file matching a list of names.
the syntax of the script is:
Code:cat list | while read f;
do
awk '{ if ($1 == "$f" ) { print } }' file ;
doneI have tested the awk command alone, and the loop itself with another command (echo $f), and it is working fine.
But for some reason, the while loop with the command awk is not working.
Would you have any idea what could be the error here?