This page describes some common utilities that should be avoided, and what you should use instead.

pidof

pidof is a strange program. It's typically a symlink to the killall5 program that's part of the sysvinit package, and is used by init to send signals to all processes. If invoked as pidof, it returns the pid of the given program. pidof Is highly nonstandard and probably used so frequently due to its intuitive name more than anything.

Alternatives

procps -- pgrep. See ProcessManagement.

killall

Alternatives

which

which is a non-standard command, though commonly available. It is useless and redundant, both in scripts and interactive shells. Some common bad usages:

# Wrong
GREP=`which grep`
...
$GREP rm logfile

What happens here is that which searches for grep in the PATH environment variable, and outputs the path to the first grep it finds. If it doesn't find it, it might output nothing, output an error to stdout, or output an error to stderr, and it may or may not return a non-zero exit status. If you happen to have a which command that outputs nothing when the command is not found, the above may result in the GREP variable being empty, in which case $GREP rm logfile expands into rm logfile, which does something else than search for the string "rm" in logfile.

# Right
grep rm logfile

Guess what, bash can also search through PATH for commands, in addition to first looking for aliases, functions or builtins by that name. So the which command added nothing useful, only bugs.

The other common use of which is to check if a command exist. The shell can do this already, and better, so why use an inferior, external command?

Alternatives

The builtins type, command and hash. See BashFAQ/081

xargs

Alternatives

expr

Alternatives

(()), let