user1516425 user1516425 - 7 months ago 36
Bash Question

Determine where a UNIX alias is defined

Is there a (somewhat) reliable way to get the 'origin' of a command, even if the command is an alias? For example, if I put this in my .bash_profile

alias lsa="ls -A"

and I wanted to know from the command-line where
is defined, is that possible? I know about the
command, but that doesn't seem to do it.



As Carl pointed out in his comment, type is the correct way to find out how a name is defined.

mini:~ michael$ alias foo='echo bar'
mini:~ michael$ biz() { echo bar; }
mini:~ michael$ type foo
foo is aliased to `echo bar'
mini:~ michael$ type biz
biz is a function
biz () 
    echo bar
mini:~ michael$ type [[
[[ is a shell keyword
mini:~ michael$ type printf
printf is a shell builtin
mini:~ michael$ type $(type -P printf)
/usr/bin/printf is /usr/bin/printf