So I know that where
command is a shell built in and as a result it performs faster and just finds executable files; but is there any other difference between the where
and find
commands?
They're very different beasts. where foo
in tcsh
(also in zsh
) just tells you where foo
is located in your $path
(or more exactly the different foo
commands the shells knows about by looking in the list of shell builtins and keywords, aliases and executable files found via a lookup of $PATH
(mapped to the $path
array)). find
is a fairly powerful command for searching for files according to various criteria.
For instance,
find /usr/local -type f -mtime -30 -atime +7 \( -user bob -o -user karen \) -perm -001 -exec chmod -x {} \;
will find any files in /usr/local
that are ordinary files (not directories or anything), have been modified in the last 30 days but not accessed in the past week, belong to either bob
or karen
, and are executable by other. It then chmod
s those files.
-
2
Just a sidenote: there's also the locate(1) command, which is somewhat similar to find(1) - in that it looks up for any kind of files, not just the ones in your $PATH (in other words: not just for "executable commands") - but uses a periodically rebuilt index, so it's pretty fast.
whereis
– ADDB Jul 30 '17 at 9:54find
manpage to find out all its features. – arrowd Jul 30 '17 at 10:09where
orwhereis
other then one of them is a builtin – ADDB Jul 30 '17 at 10:15where
in the TENEX C and Z shells and that is what the questioner is specifically asking about. – JdeBP Jul 30 '17 at 17:17