Yahoo Answers is shutting down on 4 May 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Using the find command in UNIX?

How would I use this command to find all files in the home directory, except for files in the 'dock' directory?

Update:

That answer doesn't exactly work when I try that. That's what I've been trying the entire time. If anyone has the exact command that I should enter in, that would be appreciated.

1 Answer

Relevance
  • ?
    Lv 5
    7 years ago

    From the find man page:

    http://linux.die.net/man/1/find

    It looks like you should be able to use the -path and -prune options:

    "-path pattern

    File name matches shell pattern pattern. The metacharacters do not treat '/' or '.' specially; so, for example,

    find . -path "./sr*sc"

    will print an entry for a directory called './src/misc' (if one exists). To ignore a whole directory tree, use -prune rather than checking every file in the tree. For example, to skip the directory 'src/emacs' and all files and directories under it, and print the names of the other files found, do something like this:

    find . -path ./src/emacs -prune -o -print

    Note that the pattern match test applies to the whole file name, starting from one of the start points named on the command line. It would only make sense to use an absolute path name here if the relevant start point is also an absolute path. This means that this command will never match anything:

    find bar -path /foo/bar/myfile -print

    The predicate -path is also supported by HP-UX find and will be in a forthcoming version of the POSIX standard."

Still have questions? Get answers by asking now.