On 02/02/2013 01:59 PM, Chris Hettrick wrote:
Hi Misc,
I made a list of the most classical UNIX commands / utilities from section one
where there is only one per letter of the english alphabet (it's for my OpenBSD
obsessed five year old son :) ). I know that this subject is very personal and
steeped in tradition and history, so I was looking for your opinions and
suggestions.
A quick note about the list: some hard choices were made concerning letters
such as c, p, m, etc. For instance, kill(1) is not included for two reasons: it
is included in the shell, and it needs ps(1) to be properly used (which
conflicts with pwd(1) which I think is _more_ useful for a UNIX beginner).
mv(1) was not included because a cp(1) and rm(1) can suffice.
<snip>
heh there is a fortune for that
A is for awk, which runs like a snail, and
B is for biff, which reads all your mail.
C is for cc, as hackers recall, while
D is for dd, the command that does all.
E is for emacs, which rebinds your keys, and
F is for fsck, which rebuilds your trees.
G is for grep, a clever detective, while
H is for halt, which may seem defective.
I is for indent, which rarely amuses, and
J is for join, which nobody uses.
K is for kill, which makes you the boss, while
L is for lex, which is missing from DOS.
M is for more, from which less was begot, and
N is for nice, which it really is not.
O is for od, which prints out things nice, while
P is for passwd, which reads in strings twice.
Q is for quota, a Berkeley-type fable, and
R is for ranlib, for sorting ar table.
S is for spell, which attempts to belittle, while
T is for true, which does very little.
U is for uniq, which is used after sort, and
V is for vi, which is hard to abort.
W is for whoami, which tells you your name, while
X is, well, X, of dubious fame.
Y is for yes, which makes an impression, and
Z is for zcat, which handles compression.
-- THE ABC'S OF UNIX
which got me thinking and I came with this terrifying monstrosity
find $(echo ${PATH} | tr ':' ' ') -perm -0100 -maxdepth 1 ! -type d \
| sed -E -f basename.sed \
| awk -f tag.awk \
| sort -n -k 1,1 \
| sort -u -k 2,2 \
| awk -f display.awk
with
basename.sed:
s/.*\/([^\/]*)$/\1/
#much faster then my first attempt "| xargs -n 1 basename"
tag.awk:
{
printf "%s %s %s\n", int(rand() * 1000), substr($0, 1, 1), $0
}
display.awk:
{
man_cmd = "man -f "$3" | tail -n 1"
man_cmd | getline man_str
printf "%s is for %s\n", $2, man_str
}
Now, the prose is a little off, but I blame the documentation writers.
I am certain mdoc(7) has a section about the rhyming characteristics
needed for .Nm on alternate lettered commands.
And let me just say I was quite pleased with my
"random pick one per letter group" system(the tag-sort nonsense)
First attempt was with awk associative arrays and that was getting nasty
quick.
So I just wanted to thank you for reminding me how much fun unix can be.
and I wish you and your son many hours of happy hacking togther.