concept
Bash Read and end of file
An unterminated final record can be assigned while read returns nonzero. A blank newline-terminated record succeeds. Nonzero may also indicate errors other than EOF.
Formal Syntax & Structure
bash syntaxbash
IFS= read -r lineReturn Value
behavior
An unterminated final record can be assigned while read returns nonzero. A blank newline-terminated record succeeds. Nonzero may also indicate errors other than EOF.
Working Example
Example Snippetbash
printf '%s' last > input.txtIFS= read -r line < input.txtprintf '%s [%s]\n' "$?" "$line"