2文字コマンドってどのくらいある?

2文字コマンド…シェルの補完で長いコマンドも楽に入力できるので短いから起動しやすいかというとちょっと微妙だけど、それよりも自分が知らない2文字コマンドがあるのか興味があったので2文字の実行可能ファイルを探す探すスクリプトを書いてみた。環境はOSX 10.7.3にてHomeBrew / Ruby 1.9.3等々が入ったMacBook Pro。コマンドを見つけたらついでにmanの出力からサマリ部分を引っ張ってくるようにした。

スクリプトは以下の通り。

for command in $(
    for x in $(locate / | grep "/..$")
      do file ${x} | grep "executable"  >/dev/null 2>&1
      if [ $? -eq 0 ] 
      then echo ${x} | sed -e "s/^.*\(..\)$/\1/"
      fi
    done | sort | uniq)
  do summary=$(man ${command} 2>/dev/null | grep -m1 " \-" | sed -e "s/^.*\(-.*\)$/\1/")
  echo "${command} ${summary}"
done

実行結果は以下の通り。所要時間は1分ほど。

ab - Apache HTTP server benchmarking tool
ac -time accounting
al - Mono Assembly Linker
ar - create and maintain library archives
as -based assemblers
at -
bc - An arbitrary precision calculator language
bg -in commands
cc - GNU project C and C++ compiler
cd -in commands
ci - check in RCS revisions
co - check out RCS revisions
cp - copy files
cu - Call up another system
dc - an arbitrary precision calculator
dd - convert and copy a file
df - display free disk space
du - display disk usage statistics
ed - text editor
ex - Vi IMproved, a programmers text editor
fc -in commands
fg -in commands
id - return user identity
ij
ir
lc - Mono License Compiler
ld - linker
ln - make links
lp - print files
ls - list directory contents
m4 - macro processor
md -MD
mv - move files
nc - arbitrary TCP and UDP connections and listens
nl - line numbering filter
nm - display name list (symbol table)
od - octal, decimal, hex, ASCII dump
pl - ASCII property list utility
pr - print files
ps - process status
ri - Ruby API reference front end
rm - remove directory entries
rs - reshape a data array
sa - print system accounting statistics
sh -Again SHell
sn - Digitally sign/verify/compare strongnames on CLR assemblies.
su - substitute user identity
tr - translate characters
tt
ul - do underlining
vi - Vi IMproved, a programmers text editor
wc - word, line, character, and byte count