Bash – Loop over the content of a file line by line 20 June 201810 October 2018 Fabien bash, Linux Leave a comment If you need to iterate over the content of a file line by line You can use this little bash trick. while read -r line; do printf '%s\n' "$line" done < "file.txt" In this case , it will simply print the line, but if you need to do an operation on the text , just insert your code into the while loop.