Loop a file line by line while IFS= read -r aLine do echo $aLine done < /path/to/file Loop a command line by line my_command | while IFS= read -r aLine do echo $aLine done