0

Is it possible to locate exactly that executable

myname

which will be run if passed to command line

> myname

locate command didn't work as expected, since it returns numerous results. Result should be exactly one, because if you run something, only one file runs. Also, result should take PATH precedence into account.

Thomas Dickey
  • 76,765
Dims
  • 3,255

1 Answers1

5

In a shell, you would normally use which or type for this, e.g.,

$ bash
$ which vile
/usr/bin/vile
$ type vile
vile is /usr/bin/vile
$ 

type is preferred, since it works with a POSIX shell, while which is a holdover from C-shell. In practice, I use a script showing the alternatives:

Thomas Dickey
  • 76,765