Command Reference Guide

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man1/!!!intro.1
________________________________________________________________
___ ___
f
find(1) find(1)
If any internationalization variable contains an invalid setting, all internationalization variables default to
C (see environ(5)).
LC_CTYPE determines the interpretation of text as single and/or multibyte characters, the classification of
characters as printable, and the characters matched by character class expressions in regular expressions.
LC_MESSAGES determines the locale that should be used to affect the format and contents of diagnostic
messages written to standard error and informative messages written to standard output.
NLSPATH determines the location of message catalogues for the processing of LC_MESSAGES.
International Code Set Support
Single- and multibyte character code sets are supported.
EXAMPLES
Search the two directories /example and /new/example for files containing the string Where are
you
and print the names of the files:
find /example /new/example -exec grep -l ’Where are you’ {} \;
Remove all files named a.out or *.o
that have not been accessed for a week:
find / \( -name a.out -o -name ’*.o’ \) -atime +7 -exec rm {} \;
Note that the spaces delimiting the escaped parentheses are required.
Print the names of all files on this machine. Avoid walking nfs directories while still printing the
nfs
mount points:
find / -fsonly hfs -print
Match only local files, and do not examine the contents of any directory found to be remotely mounted:
find / ! -local -prune -o -size +50 -print
This only works correctly if there are no local file systems mounted on top of remote directories. This exam-
ple will print all local files on the system larger than 50 blocks, without wasting time accessing remote files.
To get the same effect, but to check for files in local file systems mounted on remote directories, use:
find / -local -size +50 -print
Copy the entire file system to a disk mounted on /Disk, avoiding the recursive copy problem. Both com-
mands are equivalent (note the use of -path instead of -name):
cd /; find . ! -path ./Disk -only -print | cpio -pdxm /Disk
cd /; find . -path ./Disk -prune -o -print | cpio -pdxm /Disk
Copy the root disk to a disk mounted on /Disk, skipping all mounted file systems below
/. Note that -
xdev
does not cause / to be skipped, even though it is a mount point. This is because / is the starting
point and -xdev only affects entries below starting points.
cd /; find . -xdev -print | cpio -pdm /Disk
Change permissions on all regular files in a directory subtree to mode 444, and permissions on all direc-
tories to 555:
find pathname -type f -print | xargs chmod 444
find
pathname -type d -print | xargs chmod 555
Note that output from find was piped to xargs(1) instead of using the -exec primary. This is
because when a large number of files or directories is to be processed by a single command, the
-
exec
primary spawns a separate process for each file or directory, whereas xargs collects file names
or directory names into multiple arguments to a single chmod command, resulting in fewer processes
and greater system efficiency. The + delimiter for the -exec primary can be used to achieve the
same efficiency.
Access Control List Examples
Find all files not owned by user karl that have access control lists with at least one entry associated with
karl, and one entry for no specific user in group bin with the read bit on and the write bit off:
find / ! -user karl -acl ’karl.*, %.bin+r-w’ -print
HP-UX Release 11i: December 2000 − 5 − Section 1−−275
___
___