I am tailing lines from a file. And I need to iterate through the output to do some processing.
File Content:
abcd abcd abcd
abcd abcd
abcd abcd
xyz xyz
lmno xvz
pqrs uvw xyz
Below is my snippet that I use.
file=extract.txt
for line in $(tail -n 2 ${file})
do
echo $line
done
The output that i am expecting is this
lmno xvz
pqrs uvw xyz
The out that I am seeing is this, somehow the white spaces are treated as newline printing each words in single line. Appreciate any help on this. I need to iterate through the actual lines to do some processing.
lmno
xvz
pqrs
uvw
xyz