Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parsing lines from file into variable

Status
Not open for further replies.

cmarchman

Programmer
Jun 18, 2004
56
US
Here's the problem - I am trying to place whole lines from a file, i.e.
>Directory Structure Error<
...
...
...
into a variable to conduct a search on.

$line=`grep ^">" <filename>`;

while ( $line ); do
grep -l $line *.xml;
done

What is happening is that I'm getting individual words instead of the lines placed in the variable and it appears to be acting on it as a command as I'm getting an error of

<commandfilename> =>Directory command not found

Any ideas?

Thanks,


 
Something like this ?
grep '^>' <filename> | while read line
do
grep -l "$line" *.xml
done


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top