3

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?

  • I suppose you mean whereis – ADDB Jul 30 '17 at 9:54
  • 1
    nope 'where' and 'whereis' are two different things – smhquery Jul 30 '17 at 10:03
  • Other difference? So the fact that former is just a shell builtin and the latter is a full-fledged program with plenty of functionality is not enough? Read find manpage to find out all its features. – arrowd Jul 30 '17 at 10:09
  • I don't seem to find a difference between where or whereis other then one of them is a builtin – ADDB Jul 30 '17 at 10:15
  • 1
    Then you should ask a question, ADDB, because there most definitely is one. But question comments on a rather different question are not the place for this. There is a shell built-in named where in the TENEX C and Z shells and that is what the questioner is specifically asking about. – JdeBP Jul 30 '17 at 17:17
3

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 chmods those files.

  • 2
    locate may also be of interest, even though not mentioned in the Q – Hannu Jul 31 '17 at 15:14
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.