Looping through a file line by line
suggest changewhile IFS= read -r line; do
echo "$line"
done <file
If file may not include a newline at the end, then:
while IFS= read -r line || [ -n "$line" ]; do
echo "$line"
done <file
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents