How can you process a file line by line in ksh?
Asked
Active
Viewed 1.1k times
2 Answers
6
somthing like:
while read LINEVAR ; do echo ${LINEVAR} ; done < myfile.txt
which will read one line of input from myfile.txt at a time?

Vincent De Baere
- 1,793
- 10
- 10
-
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
-
i have an issue where the loop is not processing the last line of the file because it does not have a new-line character at the end. is there a way to fix this via "while read" or do i need to modifiy the input file? – ShoeLace Nov 29 '16 at 09:41
2
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