Bash Looping through a file line by line


Example

while 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