Created
December 27, 2011 20:32
-
-
Save macolyte/1525044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, subprocess | |
desc = [] | |
c_line = "man 1 %s | col -b > /tmp/man.txt" | |
s_line = "cat /tmp/man.txt | sed -n -e \"/^NAME/,/^SYNOPSIS/ p\" | grep -v -e \"^[A-Z]\"" | |
dirs = ["/usr/bin/", "/usr/sbin/"] | |
for dir in dirs: | |
for f in os.listdir(dir): | |
cmd = c_line % f | |
tmp = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) | |
p = subprocess.Popen(s_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
out = p.stdout.read().strip() | |
desc.append(out) | |
good_stuff = [x for x in desc if x] | |
outfile = open("commands.txt", "w") | |
for item in good_stuff: | |
print>>outfile, item | |
outfile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment