Conclua a abordagem awk
+ wc
:
Amostra file.txt
:
football
tennis
hockey
basketball
boxing
awk -v t=$(wc -l file.txt | cut -d' ' -f1) '{ printf "%s[%d/%d]\n",(/ball/? $0" ":""),NR,t }' file.txt
A saída:
football [1/4]
[2/4]
[3/4]
basketball [4/4]
[5/5]