Use Bash to read line by line and keep space
bash
Solution
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
Problem
When I use "cat test.file", it will show ``` 1 2 3 4 ``` When I use the Bash file, ``` cat test.file | while read data do echo "$data" done ``` It will show ``` 1 2 3 4 ``` How could I make the result just like the original test file?