"which" and "whence" Re: "whereis" versus "type"

Bill Ricker N1VUX wdr at TheWorld.com
Sun Nov 27 16:41:01 EST 2005


There's also "which", which is also an external program, and thus shares the
alias-unawareness of whereis, but does restrict itself to $PATH and (unless -a
given) will pick the one a POSIX-compliant shell would choose (meaning not
chmod'd +x for you should be ignored?).

Bash extension "type" is specifically for determining if a commandname is a
builtin, function, alias, keyword, or executable filename in a given context;
if a file, it says which one.   
The newer Korn shell ksh93 implements 'type' as an alias 
  type='whence -v'
which could be done in ksh88, but apparently didn't ship with that as a
default?
Possibly obviously, "whence" is a builtin in KSH93 which very much like BASH
"Type". KSH "whence" apparently would default to less verbose than "type", and
does not have the -T or -P options.

<<whence [  -afpv  ] name  . . .
    For each name, indicate how it would be interpreted if used as a command
name.
    The -v option produces a more verbose report. The -f options skips the
search for functions. The -p option does a path search for name  even if name
is an alias, a function, or a reserved word. The -a option is similar to the
-v option but causes all interpretations of the given name to be reported.>>
[man ksh93(1)]

Cheers,

Bill in Boston



More information about the gnhlug-discuss mailing list