On 6/21/19 12:13 PM, Jude DaShiell wrote:
> Also, man which
> If you get a chance the linux cookbook will be informative reading given
> your new position.

Please do *not* use /usr/bin/which, especially not if you write scripts.
It is non-POSIX, not portable between different different systems if you
write scripts, and even on an interactive console where you know you
personally have the "which" package installed, the results are more
confusing and less useful than using the native shell introspection.

use `command -v` to find where a command exists, or, in bash, `type -a`
if you want to see all possible options.

For more details, see:
https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then/85250#85250
Especially note the "Status today" paragraphs, and if you stubbornly
wish to continue using "which" despite its well-known pitfalls, then
carefully avoid any systems where "which" is implemented as a csh script
(like many commercial Unix systems today).

...

Use the "conflict" command if you're afraid you may have multiple
versions of an externally available executable file in your $PATH and
you want to check where they are and what you're actually using.

Since the common use case of "which" is when you actually want to know
whether you're using the wrong version of something, the ideal
interactive debugging tool is "type -a"... but the "conflict" command
can do one better -- limited to executables and not shell builtins,
aliases, or functions -- and list *all* conflicting command binaries.

-- 
Eli Schwartz
Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to