Reading Files Line by Line
while read loops over lines. Use IFS= and -r to keep whitespace.
Example
f=$(mktemp)
printf "one\n two\nthree\n" > "$f"
while IFS= read -r line; do echo "[$line]"; done < "$f"
rm "$f"Result
[one] [ two] [three]
Exercise
Keep spaces.
while = read -r l
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.