faqts : Computers : Programming : Languages : Unix Shell

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

367 of 390 people (94%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

how to read a text file line by line using Korn Shell

Aug 14th, 2002 10:58
Allan Caetano, Jim Snyder, Farouk Kadri,


#!/bin/ksh
while read line_by_line
do
      echo ${line_by_line}
done < myfile.txt
A slightly more complicated, but more flexible, version:
#!/bin/ksh
exec 4<yourfile.txt
while read each_line <&4
do
    print ${each_line}
done
exec 4<&-