📄 a
字号:
find . -fsonly hfs -print find . -print -fstype hfs -only find . -print ! -fstype hfs -prune Note, however, that -only is useless if the -depth option has also been given. Always true. ( expression ) True if the parenthesized expression is true. The spaces are required. Parentheses are special to the shell and must be escaped, as in \( and \). Primaries can be combined by using the following operators (in order of decreasing precedence): ! expression Logical NOT operator. True if expression is not true. expression [-a] expression Logical AND operator. True if both of the expressions are true. expression -o expression Logical OR operator. True if either or both of the expressions are true. Hewlett-Packard Company - 6 - HP-UX Release 11i: November 2000 find(1) find(1) If expression is omitted, or if none of -print, -ok, -exec, -cpio, or -ncpio is specified, -print is assumed. The -user, -group, and -newer primaries each evaluate their respective arguments once. HFS Access Control Lists The -acl primary enables the user to search for HFS access control list entries. It is true if the file's access control list matches an access control list pattern or contains optional access control list entries (see acl(5)). It has three forms: -acl aclpatt Match all files whose access control list includes all (zero or more) pattern entries specified by the aclpatt pattern. -acl =aclpatt Match a file only if its access control list includes all (zero or more) pattern entries specified by the aclpatt pattern, and every entry in its access control list is matched by at least one pattern entry specified in the aclpatt pattern. -acl opt Match all files containing optional access control list entries. The aclpatt string can be given as an operator or short form pattern; see acl(5). By default, -acl is true for files whose access control lists include all the (zero or more) access control list patterns in aclpatt. A file's access control list can also contain unmatched entries. If aclpatt begins with =, the remainder of the string must match all entries in a file's access control list. The aclpatt string (by default, or the part following =) can be either an access control list or an access control list pattern. However, if it is an access control list, aclpatt must include at least the three base entries ((user.%, mode), (%.group, mode), and (%.%, mode)). As a special case, if aclpatt is the word opt, the primary is true for files with access control list entries. JFS Access Control Lists The -aclv primary enables the user to search for JFS access control list entries. It is true if the file's access control list matches an access control list pattern or contains optional access control list entries (see aclv(5)). It has three forms: -aclv aclpatt Match all files whose access control list includes all (zero or more) pattern entries specified by the aclpatt pattern. Hewlett-Packard Company - 7 - HP-UX Release 11i: November 2000 find(1) find(1) -aclv =aclpatt Match a file only if its access control list includes all (zero or more) pattern entries specified by the aclpatt pattern, and every entry in its access control list is matched by at least one pattern entry specified in the aclpatt pattern. -aclv opt Match all files containing optional access control list entries. By default, -aclv is true for files whose access control lists include all the (zero or more) access control list patterns in aclpatt. A file's access control list can also contain unmatched entries. If aclpatt begins with =, the remainder of the string must match all entries in a file's access control list. An aclpatt consists of a type field, an ID field, and a mode field, separated by colons. Multiple comma-separated aclpatts may be specified. The type field is one of user, group, class, other or *, optionally preceded by default:. user, group, class, other and default can be abbreviated to u, g, c, o and d, respectively. A type field of * matches any of the above types. The ID field is either a numeric user or group ID, a user or group ID string from /etc/passwd or /etc/group respectively, or *, which matches any ID. The mode field consists of a string of three characters. The first character is either r, indicating that read permission is granted; -, indicating that read permission is denied; or ?, which matches either state of read permission. The second character is either w, -, or ?, similarly indicating the state of write permission; and the third character is either x, -, or ?, indicating the state of execute permission. As a special case, if aclpatt is the word opt, the primary is true for files with optional access control list entries. EXTERNAL INFLUENCES 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. Hewlett-Packard Company - 8 - HP-UX Release 11i: November 2000 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 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: Hewlett-Packard Company - 9 - HP-UX Release 11i: November 2000 find(1) find(1) find / -local -size +50 -print Copy the entire file system to a disk mounted on /Disk, avoiding the recursive copy problem. Both commands 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 directories 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 Find all files that have a read bit set in any access control list entry: find / -acl '*.*+r' -print Find all files that have the write bit unset and execute bit set in every access control list entry: find / -acl '=*.*-w+x' -print Find all files that have optional access control list entries: Hewlett-Packard Company - 10 - HP-UX Release 11i: November 2000 find(1) find(1) find / -acl opt -print DEPENDENCIES NFS The -acl primary is always false for NFS files. WARNINGS Because of interoperability goals, cpio does not support archiving files larger than 2GB or files that have user/group IDs larger than 60,000 (60K). Files with user/group IDs greater than 60K are archived and restored under the user/group ID of the current process. AUTHOR find was developed by AT&T and HP. FILES /etc/group Group names /etc/mnttab Mount points /etc/passwd User names SEE ALSO chacl(1), chmod(1), cpio(1), setacl(1), sh(1), test(1), xargs(1), mknod(2), stat(2), cpio(4), fs(4), group(4), passwd(4), acl(5), aclv(5), environ(5), lang(5), regexp(5). STANDARDS CONFORMANCE find: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2 Hewlett-Packard Company - 11 - HP-UX Release 11i: November 2000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -