Skip to content

Instantly share code, notes, and snippets.

@adamv
Created November 5, 2010 04:24
Show Gist options
  • Save adamv/663639 to your computer and use it in GitHub Desktop.
Save adamv/663639 to your computer and use it in GitHub Desktop.
Search for man pages
#!/usr/bin/ruby
search = ARGV.first
manpath = `manpath`.split(':')
pages = Dir["/usr/share/man/man?/*"].map do |f|
File.basename f
end.map do |f|
f =~ /(.+?)(\.(gz|bz2|lzma|Z))?$/
$1
end.grep(/.*#{Regexp.escape search}.*/i).sort
puts pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment