Cat with new line
bash
Solution
you need to set `IFS` to newline `\n`
IFS=$"\n"
for groupline in $(cat file)
do
echo "$groupline";
done
Or put double quotes. See here for explanation
for groupline in "$(cat file)"
do
echo "$groupline";
done
without meddling with IFS, the "proper" way is to use while read loop
while read -r line
do
echo "$line"
done <"file"
Problem
My input file's contents are: welcome welcome1 welcome2 My script is: ``` for groupline in `cat file` do echo $groupline; done ``` I got the following output: ``` welcome welcome1 welcome2 ``` Why doesn't it print the empty line?