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 lsa
is defined, is that possible? I know about the which
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With