numbers.sh 258 Bytes
Newer Older
Sylvain Schmitz's avatar
Sylvain Schmitz committed
1 2 3 4
#!/bin/bash

file=$1
shift
5 6 7 8
total=`grep "$1" $file | wc -l`
#printf "& $total "
shift

Sylvain Schmitz's avatar
Sylvain Schmitz committed
9 10 11

while test ${#} -gt 0
do
12 13 14 15
    count=`grep "$1" $file | wc -l`
    percent=`bc <<< "100*$count/$total"`
    printf "& $percent\\%% "
    #printf "& $count "
Sylvain Schmitz's avatar
Sylvain Schmitz committed
16 17 18
    shift
done