Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Created October 29, 2014 19:45
Show Gist options
  • Save garybernhardt/e4910b80e8ccda9f3538 to your computer and use it in GitHub Desktop.
Save garybernhardt/e4910b80e8ccda9f3538 to your computer and use it in GitHub Desktop.
find $(manpath | tr ':' '\n') -iname '*.1' | xargs cat | (LC_CTYPE=C tr -C '[:alnum:]-_' '\n') | egrep '^--[\-_[:alnum:]]+$' | sort | uniq -c | sort -n
@garybernhardt
Copy link
Author

the final sort is sort -n

@mgedmin
Copy link

mgedmin commented Oct 29, 2014

Now I'm wondering what are those 162 commands that support --1v. And I suspect 28 -----syntax and 17 -----examples aren't really options.

@mgedmin
Copy link

mgedmin commented Oct 29, 2014

(It's difficult to copy and paste a line of text from a horizontally-scrolling div. I accidentally the final -n. Sorry.)

@schmonz
Copy link

schmonz commented Oct 29, 2014

:; find $(manpath | tr ':' '\n') -iname '*.1' | xargs cat | (LC_CTYPE=C tr -C '[:alnum:]-_' '\n') | perl -ne 'print if /^--[\w-]+$/' | grep -v '^-*$' | sort | uniq -c | sort -n
ksh: manpath: not found
tr: unknown option -- C
usage: tr [-cs] string1 string2
       tr [-c] -d string1
       tr [-c] -s string1
       tr [-c] -ds string1 string2
find: unknown option -- i
find: unknown option -- n
find: unknown option -- a
find: unknown option -- m
find: unknown option -- e
find: *.1: No such file or directory

:; uname -mrs
NetBSD 6.1.5 amd64

(FWIW, if I were chasing portability in shell programming, I'd probably punt on making this a one-liner. Make a script, define well-named functions, make their composition evident, then futz with implementation details of each function.)

@garybernhardt
Copy link
Author

OS X's zcat append ".Z" to all paths not already ending with it, so that doesn't work. Using gzcat instead fails because it tries to decompress everything, so uncompressed man pages blow up. I bet that Ubuntu has saved its users as much as ten megabytes of disk space by compressing the man pages! :/

@garybernhardt
Copy link
Author

triple click selects full lines of text, which is useful for situations like this (although I don't know whether various Linux dinguses will do the right thing there; probably not)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment