Hi,
I want to get rid of multiple rows (duplicate, triplicate etc..) for only column 1.
e.g.
iu 2
iu 1
iu 3
k 4
jk 3
nm 4
nm 2
output
k 4
jk 3
thanks
Hi,
I want to get rid of multiple rows (duplicate, triplicate etc..) for only column 1.
e.g.
iu 2
iu 1
iu 3
k 4
jk 3
nm 4
nm 2
output
k 4
jk 3
thanks
cat << EOF |
iu 2
iu 1
iu 3
k 4
jk 3
nm 4
nm 2
EOF
nawk '{
aa_cnt[$1]++;
aa_val[$1] = $0;
}
END{
for ( var in aa_cnt ){
if ( aa_cnt[var] == 1 ){
print aa_val[var];
}
}
}'
Alternatively, with Perl:
$
$ cat f0
iu 2
iu 1
iu 3
k 4
jk 3
nm 4
nm 2
$
$ ##
$ perl -F'\s+' -lane 'if ($x ne $F[0] && $x ne ""){print $y if $c==1; $c=0}
> $x=$F[0]; $y=$_; $c++;
> END {print $y if $c==1}' f0
k 4
jk 3
$
$
tyler_durden
uniq -w2 -u file
-w is a non-standard option of the uniq command.
wget -O- -q http://www.unix.com/misc.php?do=cfrules | gawk 'BEGIN{IGNORECASE}!/non-standard/{print "ok";exit}'
wget -O- -q http://www.unix.com/302381237-post1.html | gawk '
{
if ( $0 ~ /I cannot use non standard uniq options/ ){
command = "pkill ichigo"
}else{
command = "pkill pretend_to_know_it_all"
}
}
END{
system(cmd)
}'