Notice! This document is currently in
Archived
status.
The content of this document may be incorrect or outdated.
The content of this document may be incorrect or outdated.
Print this article Edit this article
UNIX Commands: Using "find"
- ECN discourages the use of find for searching an entire file system because it loads down the machine which is impolite to other users.
- It is suggested that you use the "whereis" tool located in /usr/ucb/whereis
However, to help you understand find, here is a synopsis of the man page:
find - find files
find path-name-list expression
path-name-list is the Full path name to the directory from which you
wish to start the seqrch.
expression is a sequence of the different options listed in the
man page. Some options require a pattern or integer.
A space between different options means 'logical and' and
a "-o" between different options means 'logical or'
Here are some useful examples:
EXAMPLES
Remove all files in your home directory named a.out or * .o
that have not been accessed for a week:
example% find $HOME \( -name a.out -o -name '*.o' \) - atime
+7 -exec rm {} \;
Recursively print all file names in the current directory
and below, but skipping SCCS directories:
example% find . -name SCCS -prune -o -print
Recursively print all file names in the current directory
and below, skipping the contents of SCCS directories, but
printing out the SCCS directory name:
example% find . -print -name SCCS -prune
find will only search directory trees in which you have permission to search.
It is often useful to set up a directory tree in your home directory
and play with the various options until you understand how the options
you want to use work. It is faster.
Also remember, find is silent. If you want to know the results of its
search '-print' MUST be the last option in expression.
The simplest use to find a file is:
find (dir) -name (file) -print
Last Modified:
Dec 19, 2016 11:12 am US/Eastern
Created:
May 24, 2007 2:08 pm GMT-4
by
admin
JumpURL: