Read the file line by line and search for wor

August 12, 2011 at 05:09:34
Specs: Windows XP
Hi friends,

I am new to unix, i need to write the scripts which read the file line by line and search for the pattern and print it and then conutine in reading the file and start searching for another pattern in the file till the end of the file.. please help


See More: Read the file line by line and search for wor

Report •

#1
August 12, 2011 at 11:48:56
Why do you need to read to read the file line by line? The unix grep command searches the entire file:

grep "pattern" datafile.txt

If you still insist on reading a file line by line, this is a way to do it:

#!/bin/ksh

while read line
do
   echo "$line"
done < datafile.txt


Report •
Related Solutions


Ask Question