Bash's for loop breaks up its input using the internal field separator - $IFS. Try : ORIGIFS=$IFS # set $IFS to end-of-line IFS=`echo -en "\n\b"` for i in $lines; do echo $i done # set $IFS back IFS=$ORIGIFS