Posts

Showing posts with the label graph

Beginning graphing

Image
One of the simplest graphs I have seen can be done in bash. You will need a data file and a one line executable to extract the data from the file and then display it. data: Irene     10 Karen     37 Andreas   41 Beatrice  23 Code: SCALE=1; WIDTHL=10; WIDTHR=60; BAR="12345678"; BAR="${BAR//?/==========}"; while read LEFT RIGHT rest ; do RIGHT=$((RIGHT/SCALE)); printf "%${WIDTHL}s: %-${WIDTHR}s\n" "${LEFT:0:$WIDTHL}" "|${BAR:0:$RIGHT}*"; done < data Result:    Irene: |==========*                                                  Karen: |=====================================*                ...