Friday, 19 October 2012

awk + split

sam@sam-Lenovo-G450:~$ cat sam
echo hi
hi this is sam
hare u getting ma msg
if it so please ping reply

-------------------------------------------------------------------------------------------

sam@sam-Lenovo-G450:~$ cat sam | gawk '{IGNORECASE=1} {c=split($0,s) ; for(i=0;i<=c;i++) {printf s[i]"\n" }}'

echo
hi

hi
this
is
sam

hare
u
getting
ma
msg

if
it
so
please
ping
reply

---------------------------------------------------------------------------------------------------

word grep

cat sam | gawk '{IGNORECASE=1} {c=split($0,s) ; for(i=0;i<=c;i++) {if(s[i]=="msg") {print $0}}}'

No comments:

Post a Comment