Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have command foo, how can I know if it's binary, a function or alias?

share|improve this question
    
Related: unix.stackexchange.com/questions/85249/… –  slm Sep 1 '13 at 13:28

2 Answers 2

up vote 10 down vote accepted

If you're on Bash (or another Bourne-like shell), you can use type.

type command

will tell you whether command is a shell built-in, alias (and if so, aliased to what), function (and if so it will list the function body) or stored in a file (and if so, the path to the file).

For more information on a "binary" file, you can do

file "$(type -P command)" 2>/dev/null

This will return nothing if command is an alias, function or shell built-in but returns more information if it's a script or a compiled binary.

References

share|improve this answer

The answer will depends on which shell you're using.

For zsh, shell builtin whence -w will tell you exactly what you want

e.g.

$ whence -w whence
whence : builtin
$ whence -w man     
man : command 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.