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 e
read data will split the data by IFS, which is typically " \t\n". This will preserve the blanks for you:
read data
var=$(cat test.file) echo "$var"