Skip to content

Instantly share code, notes, and snippets.

@brett-miller
Created April 22, 2017 05:21
Show Gist options
  • Save brett-miller/af50d0672b538099181a12cd983522f2 to your computer and use it in GitHub Desktop.
Save brett-miller/af50d0672b538099181a12cd983522f2 to your computer and use it in GitHub Desktop.
count of man pages by section
#!/bin/sh
# apropos . - whatis database
# sed 's/\s*\(.*\)-.*/\1/' - remove content to the right of '-'
# sed -e $'s/,/\\\n/g' - split likes on ','
# grep \(.*\) - remove lines without a section
# sed 's/[^)]*(\([^)]*\)).*/\1/' - extract the section string
# awk '{arr[$1]++}END{for (a in arr) print a, arr[a]}' - get count of each section ($1)
# sort -nrk2 - sort by number in reverse order on column 2
# column -t - format in readable columns
apropos . | sed 's/\s*\(.*\)-.*/\1/' | sed -e $'s/,/\\\n/g' | grep \(.*\) | sed 's/[^)]*(\([^)]*\)).*/\1/' | awk '{arr[$1]++}END{for (a in arr) print a, arr[a]}' | sort -nrk2 | head -n 25 | column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment