[quotes]
Dear Masters,
Need your help for this small query.
I am trying to get all the strings that starts with a blank space as output.
Limitation is , it should be done only through AWK.
Input will be:
aa
_1bbb
c-ccc
ddd
eeeee
ff
Output should be:
_1bbb
c-ccc
eeee
ff
ctsgnb
March 18, 2011, 4:31pm
4
print all lines starting with blank :
awk '/^[[:blank:]]/' infile
print all lines except those starting with blank:
awk '!/^[[:blank:]]/' infile
Thanks to ALL for your reply.
For reply:1 -> I'm getting the output as:
awk '/^ /' infile
_1bbb yes
c-ccc yes
eeeee yes
ff yes
But when I tried something as below, inorder to do conditional manipulation based on the value of $1, I didn't get any output.
>awk '{ if($1 ~ /^ /) {print $0}}' infile
For reply:2 -> I'm not getting the desired output which I think may be because [:blank:] searches for tab space.
>awk '/^[[:blank:]]/' infile ---> no output
>awk '!/^[[:blank:]]/' infile
aa no
_1bbb yes
c-ccc yes
ddd no
eeeee yes
ff yes
FYI, my infile have below contents:
>cat infile
aa no
_1bbb yes
c-ccc yes
ddd no
eeeee yes
ff yes
Regards,
This works correctly for me
$ awk '/^[[:blank:]]/' file
_1bbb yes
c-ccc yes
eeeee yes
ff yes
Perhaps you need to use nawk or gawk.