Vous êtes sur la page 1sur 5

find . -size +150000800c 2>/dev/null The following comand removes all files in your home directory named a.

out or *.o that have not been accessed for a week: find proj/GMGIFFMDI/ArchiveZone/Diff \( -name '*.dif' -o -name '*.o' \) -exec rm {} \; ls -l awk '{if ($5 >314572800) print $0}'

Complex Expressions The primaries can be combined using the following operators (in order of decreasing precedence): 1) ( expression ) True if the parenthesized expression is true (parentheses are special to the shell and must be escaped). The negation of a primary (! is the unary not operator). Concatenation of primaries (the and operation is implied by the juxtaposition of two primaries). Alternation of primaries (-o is the or operator).

2)

! expression

3) expression [-a] expression

4) expression -o expression

When you use find in conjunction with cpio, if you use the -L option with cpio then you must use the -follow expression with find and vice versa. Otherwise there are undesirable results. SunOS 5.10 User Commands Last change: 9 Feb 2009 7 find(1)

If no expression is present, -print is used as the expression. Otherwise, if the given expression does not contain any of the primaries -exec, -ls, -ok, or -print, the given expression is effectively replaced by: ( given_expression ) -print The -user, -group, and -newer primaries each evaluate their respective arguments only once. Invocation of command specified by -exec or -ok does not affect subsequent primaries on the same file. USAGE See largefile(5) for the description of the behavior of find when encountering files greater than or equal to 2 Gbyte (

2^31 bytes). EXAMPLES Example 1 Writing Out the Hierarchy Directory The following commands are equivalent: example% find . example% find . -print They both write out the entire directory hierarchy from the current directory. Example 2 Removing Files The following comand removes 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 {} \; Example 3 Printing All File Names But Skipping SCCS Directories SunOS 5.10 User Commands Last change: 9 Feb 2009 8 find(1)

The following command recursively print all file names in the current directory and below, but skipping SCCS directories: example% find . -name SCCS -prune -o -print Example 4 Printing all file names and the SCCS directory name 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 Example 5 Testing for the Newer File The following command is basically equivalent to the -nt extension to test(1): example$ if [ -n "$(find file1 -prune -newer file2)" ]; then printf %s\\n "file1 is newer than file2" Example 6 Selecting a File Using 24-hour Mode The descriptions of -atime, -ctime, and -mtime use the terminology n ``24-hour periods''. For example, a file accessed at 23:59 is selected by:

example% find . -atime -1 -print at 00:01 the next day (less than 24 hours later, not more than one day ago). The midnight boundary between days has no effect on the 24-hour calculation. SunOS 5.10 User Commands Last change: 9 Feb 2009 9 find(1)

Example 7 Printing Files Matching a User's Permission Mode The following command recursively print all file names whose permission mode exactly matches read, write, and execute access for user, and read and execute access for group and other: example% find . -perm u=rwx,g=rx,o=rx The above could alternatively be specified as follows: example% find . -perm a=rwx,g-w,o-w Example 8 Printing Files with Write Access for other The following command recursively print all file names whose permission includes, but is not limited to, write access for other: example% find . -perm -o+w Example 9 Printing Local Files without Descending Non-local Directories example% find . ! -local -prune -o -print Example 10 Printing the Files in the Name Space Possessing Extended Attributes example% find . -xattr ENVIRONMENT VARIABLES See environ(5) for descriptions of the following environment variables that affect the execution of find: LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH. SunOS 5.10 User Commands PATH Last change: 9 Feb 2009 10 find(1) Determine the location of the utility_name for the -exec and -ok primaries.

EXIT STATUS The following exit values are returned: 0 >0 All path operands were traversed successfully. An error occurred.

FILES /etc/passwd /etc/group /etc/dfs/fstypes Password file Group file File that registers distributed file system packages

ATTRIBUTES See attributes(5) for descriptions of the following attributes: ____________________________________________________________ ATTRIBUTE TYPE ATTRIBUTE VALUE _____________________________ _____________________________ Availability SUNWcsu _____________________________ _____________________________ CSI Enabled _____________________________ _____________________________ Interface Stability Committed _____________________________ _____________________________ Standard See standards(5). _____________________________ _____________________________ SEE ALSO chmod(1), cpio(1), ls(1B), sh(1), test(1), acl(2), stat(2), umask(2), attributes(5), environ(5), fsattr(5), largefile(5), standards(5) WARNINGS The following options are obsolete and will not be supported in future releases: SunOS 5.10 User Commands -cpio device Last change: 9 Feb 2009 11 find(1) Always true. Writes the current file on device in cpio format (5120-byte records). Always true. Writes the current file on device in cpio -c format (5120-byte records).

-ncpio device

NOTES When using find to determine files modified within a range of time, use the -mtime argument before the -print argument. Otherwise, find gives all files. Some files that might be under the Solaris root file system are actually mount points for virtual file systems, such as mntfs or namefs. When comparing against a ufs file system, such files are not selected if -mount or -xdev is specified in the find expression. Using the -L or -follow option is not recommended when descending a file-system hierarchy that is under the control of other users. In particular, when using -exec, symbolic links

can lead the find command out of the hierarchy in which it started. Using -type is not sufficient to restrict the type of files on which the -exec command operates, because there is an inherent race condition between the type-check performed by the find command and the time the executed command operates on the file argument. SunOS 5.10 Last change: 9 Feb 2009 12

Vous aimerez peut-être aussi