0

I have this command that I run. Let's call it foo. I can execute foo without specify the full path to foo like so:

$ foo
missing args

I suspect foo is a bash script so I want to look at the source code in foo, but when I do which foo I get the standard error message:

which: no foo in (/usr/local/bin ...removed for brevity ...)

What gives?

Red Cricket
  • 2,203

1 Answers1

4

You could use the type built-in, which indicates how the argument would be interpreted if used as a command name, e.g. as a function, built-in, a binary (under $PATH)

$ f() { echo foo; }
$ type f
f is a function
f ()
{
    echo foo
}
$ type type
type is a shell builtin
$ type grep
grep is /usr/bin/grep
$ alias z='echo zee zee'
$ type z
z is aliased to `echo zee zee'

See also Why not use "which"? What to use then? for a more detailed write-up on the subject.

Inian
  • 12,807