My awk version is:GNU Awk 3.1.5
I have a data file named data1, here is the data of file data1:
Code:
hereis[ ]mydata
Ijustw[ ]ant_to_see_it_intact
between [ and ] there are 5 spaces.
when I use the bash code below, it works fine, it just prints the lines as the data file:
Code:
cat data1|awk '{print $0}'
But when I use this code, it deletes the extra spaces:
Code:
cat data1 | while read line
do
newline=$(echo ${line}|awk '{print $0 }' )
echo "${newline}"
done
the output is below, only one space between [ and ], not 5 spaces:
Code:
hereis[ ]mydata
Ijustw[ ]ant_to_see_it_intact
Please help understanding the behavior, thanks in advance.