perl -e 'while (<>){@a=split;$s{$a[0]}+=$a[1] if $a[1]}print "$_=$s{$_}$/"for sort keys %s' texto.txt [fpalacios@linuxtest fpalacios]$ cat texto.txt 12345 99 12345 99 23432 99 54567 20 [fpalacios@linuxtest fpalacios]$ perl -e 'while (<>){@a=split;$s{$a[0]}+=$a[1] if $a[1]}print "$_=$s{$_}$/"for sort keys %s' texto.txt 12345=198 23432=99 54567=20 [fpalacios@linuxtest fpalacios]$