Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can you process a file line by line in ksh?

share|improve this question
up vote 5 down vote accepted

somthing like:

while read LINEVAR ; do echo ${LINEVAR} ; done < myfile.txt

which will read one line of input from myfile.txt at a time?

share|improve this answer
Just a word of warning -- without double quotes around it, many spaces (or whatever IFS is set to) will be reduced to one space. Nulls always vanish in shells script output. Not that we need nulls for anything. But they are useful for some reason in binary files. – chris May 17 '10 at 14:24

Check bellow link, I have posted 5 different methods with timing comparison.

Different ways to process a file line by line in a shell script

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.