Use Bash to read line by line and keep space

IFS=''
cat test.file |
while read data
do
    echo "$data"
done

I realize you might have simplified the example from something that really needed a pipeline, but before someone else says it:

IFS=''
while read data; do
    echo "$data"
done < test.file

Leave a Comment