Código
#!/bin/bash nombre=pedrito coincidencias=0 while read linea do nombrel=`echo $linea | cut -d ":" -f 1` length=`echo $nombre | wc -c` for p in `seq 1 $length` do letra_linea=`echo $nombrel | cut -b $p` letra_nombre=`echo $nombre | cut -b $p` if [ ! $letra_linea ] then if [ $coincidencias -gt 0 ] then echo $linea >> agenda.tmp echo "$nombre:92051623" >> agenda.tmp else echo $linea >> agenda.tmp fi break elif [ "$letra_linea" == "$letra_nombre" ] then coincidencias=`expr $coincidencias + 1` fi done done < agenda.txt
No sabía exactamente como ordenarlos