Penguin
Diff: TwoLetterCommands
EditPageHistoryDiffInfoLikePages

Differences between current version and revision by previous author of TwoLetterCommands.

Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History

Newer page: version 10 Last edited on Thursday, January 8, 2004 2:06:45 pm by AristotlePagaltzis
Older page: version 8 Last edited on Wednesday, November 27, 2002 12:10:22 pm by DanielLawson Revert
@@ -39,11 +39,17 @@
 | wc(1) | Word Count 
  
  
 ''Since ls(1) is such an often-used and occasionally mistyped command, there's an amusing little program '[sl|http://gar.lnx-bbc.org/cvs/gar/games/sl/]' which does an animated Steam Loco.. It comes with freeBSD but there's probably a Linux port if you're really interested. - zcat'' (sl is in debian. But if you're like me the novelty will wear off pretty quickly as you can't use your terminal for a few seconds until the Steam Locomotive has gone across it). 
-  
  
 The following command will list all TwoLetterCommands on your system: 
  
  find {,/usr}/{,s}bin -type f | grep "/..$" 
  
 It looks in /bin, /usr/bin, /sbin, /usr/sbin for all files which have two letters in their name. On my Debian Woody system there are a number of ones not listed above, which are mainly just improved tools: lc is an improved wc, gw is a gnome version of 'w' (so thats a OneLetterCommand really... ;) 
+  
+''The above is wrong (or at least bad) in so many ways. It has a useless use of grep(1); find(1) can already match globs, so just tell it to look for __-name '??'__. It will recurse directories and find files not available for direct invocation (at least the [GNU] version of find(1) has __-maxdepth__ which can be used to fix this). It will also find files without execution permission. The following is much more precise.'' --AristotlePagaltzis  
+  
+ find ${PATH//:/ } -type f -name '??' -maxdepth 1 -perm +o+x  
+  
+ # if you don't have a bash-ish shell you need an extra process:  
+ find `echo $PATH | tr : ' '` -type f -name '??' -maxdepth 1 -perm +o+x