Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Uso: istogramma.sh dati.txt
- sort -k 1,1 $1 > output.tmp
- max=$(tail -1 output.tmp|awk '{print $1}')
- i=1
- puntatore=1
- rm -f result.txt
- while (( $i<=$max ))
- do
- linea=$(head -$puntatore output.tmp | tail -1)
- numero=$(echo $linea|awk '{print $1}')
- if (( $numero == $i ))
- then
- stringa=""
- asterischi=$(echo $linea|awk '{print $2}')
- for (( j=0 ; j < asterischi ; j++ ))
- do
- stringa="$stringa*"
- done
- echo "$i $stringa" >> result.txt
- puntatore=$(( $puntatore+1 ))
- else
- echo "$i" >> result.txt
- fi
- i=$(( $i+1 ))
- done
- rm -f output.tmp
Advertisement
Add Comment
Please, Sign In to add comment