BASH will actually parse the lines like you originally wanted. You can work on lines either by modifying the BASH environment variable "IFS", or by quoting your input - examples below
Example 1 #!/bin/bash # Altering IFS to only tokenise on newlines. OFS=$IFS; IFS=' ' for LINE in $(cat ~/thefile ); do echo LINE # or whatever done IFS=$OFS # reset back to original value
Example 2 #!/bin/bash # Quoting your input for LINE in "$(cat ~/thefile)"; do echo "$LINE" done
Example 1
#!/bin/bash
# Altering IFS to only tokenise on newlines.
OFS=$IFS; IFS='
'
for LINE in $(cat ~/thefile ); do
echo LINE # or whatever
done
IFS=$OFS # reset back to original value
Example 2
#!/bin/bash
# Quoting your input
for LINE in "$(cat ~/thefile)"; do
echo "$LINE"
done