I have a file containing these lines:
"RedfishVersion":"1.6.0"
"RedfishVersion":"1.6.0"
"RedfishVersion":"1.6.0"
"RedfishVersion":"1.6.0"
"RedfishVersion":"1.6.0"
"RedfishVersion":"1.6.0"
"RedfishVersion":"1.15.0"
"RedfishVersion":"1.15.0"
"RedfishVersion":"1.15.0"
"RedfishVersion":"1.15.0"
"RedfishVersion":"1.15.0"
"RedfishVersion":"1.15.0"
"RedfishVersion":"1.15.0"
I was wondering if is there a Unix way to get a histogram percentage of these lines based on how many times it's repeated. This is my attempt:
sort bmc-versions.txt | uniq -cd
321 "RedfishVersion":"1.0.0"
19 "RedfishVersion":"1.0.2"
I want output like this:
"1.0.0" 50%
"1.0.2" 40%
Sorted by percentage (highest first) using GNU awk:
Nicer formatting:
Sorted by percentage (highest first) using 'non-GNU' awk (e.g. posix awk):
Nicer formatting: