bash - Reading input files by line using read command in shell scripting - Stack Overflow
read
reads until it finds a newline character or the end of file, and returns a non-zero exit code if it encounters an end-of-file. So it's quite possible for it to both read a line and return a non-zero exit code.
Consequently, the following code is not safe if the input might not be terminated by a newline:
while read LINE; do # do something with LINE done
because the body of the while
won't be executed on the last line.
Read full article from bash - Reading input files by line using read command in shell scripting - Stack Overflow
No comments:
Post a Comment