# cat justdoit
#!/bin/bash
oldIFS=$IFS
IFS="|"
i=0 ; ix=0 ; in=0
exec <$1
while read val1 val2
do
array=$val1
let i=i+1
tmpval=$val2
if [ $i -ne 1 ] ; then
if [ ${array[ix]} -ne ${array[ix+1]} ] ; then
myval2[in]=${tmpval[i-1]}
((++in))
fi
((++ix))
fi
done
myval2[in]=${tmpval}
IFS=$oldIFS
count=${#array[@]}
in=0 ; inx=0
myval[0]=${array[0]}
while [ $(( count -=1 )) -gt -1 ]
do
same=1
for val in ${array[@]}
do
if [ $val -eq ${array[in]} ] ; then
((++same))
fi
done
var=ok
if [ $same -gt 2 ] ; then
for newval in ${myval[@]}
do
if [ ${array[in]} -ne $newval ] ; then
var=notok
else
var=ok
fi
done
fi
if [ "$var" == "notok" ] ; then
myval[inx]=${array[in]}
fi
((++in))
((++inx))
done
inx=0
for val1 in ${myval[@]}
do
echo "$val1|${myval2[inx]}"
((++inx))
done
Wow, thanks all for your answers. It really was helpfull and it allowed me to complete a program which purpose was to count the number of words in a given text file, and classify them according to the number of caracters they had. Thus, the file created with the repeating numbers - which was an effect of a counter that I placed in the part of the program which calculated the number of words per number of caracters. The only part that was missing was to find a way to take the highest value of the lines which resulted from my code, and print them instead of all those which lead to them. My knowledge in awk or bash programming is too limited for me moment to have found the way by myself, so thanks again for helping me out.