💾 Archived View for senioradmin.de › barchart.sh captured on 2021-12-03 at 14:04:38.
-=-=-=-=-=-=-
#!/bin/bash # License: https://www.gnu.org/licenses/gpl-3.0.html #set -x bar="â–ˆ" csv="$1" declare -i value=0 if [ "$csv" == "" ]; then echo "Usage: $0 <csv-file>" exit 1 fi let max=0 while read n; do value=`echo $n|cut -d, -f2` if [ $max -lt $value ]; then max=$value; fi done < $csv echo "Max: $max" while read n; do key=`echo $n|cut -d, -f1` value=`echo $n|cut -d, -f2` let hval=$value*100 let bval=$hval/$max echo -en "$key \t" for ((i=1;i<=$bval;i++)); do echo -n "$bar" done echo " $value" done < $csv