I'm trying to filter the most used commands and print that out in a certain way. So far, I've managed to put the desired "filters":
$ history | tr -s ' ' | cut -d ' ' -f3 | sort | uniq -c | sort -n | tail | awk '{ printf "%s%20s\n", $2, $1 }'
...but I can't get the output correctly.
I would like to be able to display the final output like:
checkupdates 16 ▄▄▄
find 16 ▄▄▄
./gradlew 17 ▄▄▄
./rebar3 21 ▄▄▄▄
nix-env 24 ▄▄▄▄
cd 26 ▄▄▄▄▄
docker 33 ▄▄▄▄▄▄
rebar3 43 ▄▄▄▄▄▄▄▄
sudo 46 ▄▄▄▄▄▄▄▄▄
flatpak 56 ▄▄▄▄▄▄▄▄▄▄▄
I want to use awk
or printf
, but I can't figure it out how to format the output. Also, it's tricky to manage the space between the command(s) and the next column (the usage numbers) ‒ the third one is just one space away from the second one.
PS: The scale for the ▄ can be anything.