Hi everyone,
i need small help in my shell script
i have a file like this
name name1,name2 name3,name4
hello name3,name1 name4
.
.
.
hi name4,name3 name1
my scenario is i need to get the lines from the file that has name1 in second column
What is the field separator? I've assumed the field separator in the below file as ','. Modify according to your requirements. If field separator is just white-space, remove off -F',' part.
$ cat input
name,name1,name2,name3,name4
hello,name3,name1,name4
hi,name4,name3,name1
$
$ awk -F',' '$2 == "name1"' input
name,name1,name2,name3,name4
$
Hi,
Thanks for replying back
if i have just the name1 in second column then command you gave is working fine
but some lines in my file second column looks like this
name1,name2
name3,name1
i need to want the lines like above also
I think this is what you want:
awk '$2 ~ /name1/' input
Thank you very much it helped....