Is that an alias or a command?


When executing shell commands, I occassionally find that my alias definitions collide with actual commands. This periodically causes unexpected side effects, and munges the command output when additional options and pipelines are present. Since I use the Korn shell as my primary shell, I frequently use the whence(1) shell built-in to resolve these issues:

$ whence -v ls
ls is a tracked alias for /bin/ls

$ whence -v awk
awk is /bin/awk

whence(1) will provide a summary of the command passed as an argument, which can be helpful for determining if the command is an alias, function or an actual command. If you want to view all aliases, you can use the alias(1m) command without any options:

$ alias

autoload='typeset -fu'
cat=/bin/cat
command='command '
functions='typeset -f'
history='fc -l'
integer='typeset -i'
local=typeset
ls=/bin/ls
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
suspend='kill -STOP $$'

UNIX shells contain lots of obscure commands and functionality, and are one of the coolest things to learn about!!

This article was posted by Matty on 2005-10-07 13:05:00 -0400 -0400