cat test.txt
#this is comment
line 1
line 2
#this is comment at line 3
line4
script:
result=`awk '/^#.*/ { print }' test.txt `
for x in $result
do
echo x
done
expected output:
#this is comment
#this is comment at line 3
getting output:
#this
is
comment
#this
is
comment
at
line
3
but when i execute this command awk '/^#.*/ { print }' test.txt,
i get expected result.
I am putting this in loop because I need to capture each comment one at a time, not all together.