HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)

f
find(1) find(1)
Environment Variables
If an internationalization variable is not specified or is null, it defaults to the value of
LANG.
If
LANG is not specified or is null, it defaults to
C (see lang(5)).
If
LC_ALL is set to a nonempty string value, it overrides the values of all the other internationalization
variables.
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 a single long listing of all files named *.o in the current directory:
find . -name ’*.o’ -exec ls -l {} \+
find . -name ’*.o’ -exec ls -l \+
Note that the curly braces, before plus sign, are optional.
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
example 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
Section 1284 Hewlett-Packard Company 5 HP-UX 11i Version 1: September 2005