Hi ,
I have a similar problem.
Please can anyone help me with a shell script or a perl.
I have a flat file like this
fruit country
apple germany
apple india
banana pakistan
banana saudi
mango india
I want to get a output like
fruit country
apple germany
banana pakistan
mango india
Is there anyways this can be done?
awk '{a[$1]++}a[$1]<2' file
Thanks sir. Please also tell me how this can be sent to a file
awk '{a[$1]++}a[$1]<2' file > new.file
Thanks Mate for this.
Unforfunately other module have decided to send a comma seperated file instead of space seperated. Please help again .
I have values like this now
INDIA,mango,2
PAK,mango,1
USA,apple,1
UK,apple,1
smalya:
Thanks Mate for this.
Unforfunately other module have decided to send a comma seperated file instead of space seperated. Please help again .
I have values like this now
INDIA,mango,2
PAK,mango,1
USA,apple,1
UK,apple,1
A little modificatiion to danmero solution...
awk -F, '{a[$1]++}a[$1]<2' file > new.file
i guess you might need to change $1 to $2...
awk -F "," '{a[$2]++}a[$2]<2' file2
cheers,
Devaraj Takhellambam
Shorter:
awk -F "," '!a[$2]++' file