实例
find 路径 查找类型 相应类型
find ./ -name filename 查询当前路径文件
find ./ -name filename1 -o filename2 查找1或2文件
find ./ -name filename ! -ftype vfat 查找文件类型不为vfat的文件
语法
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point…] [expression]
参数
HLP
-D debugoptions
-Olevel
EXPRESSION
POSITIONAL OPTIONS
GLOBAL OPTIONS
TESTS
参数 | 描述 |
---|---|
+n | for greater than n, |
-n | for less than n, |
n | for exactly n. |
-amin n | File was last accessed n minutes ago. |
-anewer file | File was last accessed more recently than file was modified. |
-atime n | File was last accessed n*24 hours ago. |
-cmin n | File’s status was last changed n minutes ago. |
-cnewer file | File’s status was last changed more recently than file was modified. |
-ctime n | File’s status was last changed n*24 hours ago. |
-empty | File is empty and is either a regular file or a directory. |
-executable | Matches files which are executable and directories which are searchable (in a file name resolution sense). |
-false | Always false. |
-fstype type | File is on a filesystem of type type. |
-gid n | File’s numeric group ID is n. |
-group gname | File belongs to group gname (numeric group ID allowed). |
-ilname pattern | Like -lname, but the match is case insensitive. |
-iname pattern | Like -name, but the match is case insensitive. |
-inum n | File has inode number n. |
-ipath pattern | Like -path. but the match is case insensitive. |
-iregex pattern | Like -regex, but the match is case insensitive. |
-links n | File has n links. |
-lname pattern | File is a symbolic link whose contents match shell pattern pattern. |
-mmin n | File’s data was last modified n minutes ago. |
-mtime n | File’s data was last modified n*24 hours ago. |
-name pattern | Base of file name (the path with the leading directories removed) matches shell pattern pattern. |
-newer file | File was modified more recently than file. |
-newerXY reference | Succeeds if timestamp X of the file being considered is newer than timestamp Y of the file reference. |
-nogroup | No group corresponds to file’s numeric group ID. |
-nouser | No user corresponds to file’s numeric user ID. |
-path pattern | File name matches shell pattern pattern. |
-perm mode | File’s permission bits are exactly mode (octal or symbolic). |
-perm -mode | All of the permission bits mode are set for the file. |
-perm /mode | Any of the permission bits mode are set for the file. |
-readable | Matches files which are readable. |
-regex pattern | File name matches regular expression pattern. |
-samefile name | File refers to the same inode as name. |
-size n[cwbkMG] | File uses n units of space, rounding up. |
-type c | File is of type c |
-uid n | File’s numeric user ID is n. |
-used n | File was last accessed n days after its status was last changed. |
-user uname | File is owned by user uname (numeric user ID allowed). |
-writable | Matches files which are writable. |
-context pattern | (SELinux only) Security context of the file matches glob pattern. |
ACTION
参数 | 描述 |
---|---|
-delete | Delete files; true if removal succeeded. |
-exec command ; | Execute command; true if 0 status is returned. |
-exec command {} + | |
-execdir command ; | |
-execdir command {} + | |
-fls file | True; like -ls but write to file like -fprint. |
-fprint file | True; print the full file name into file file. |
-fprint0 file | rue; like -print0 but write to file like -fprint. |
-fprintf file format | True; like -printf but write to file like -fprint. |
-ls | True; list current file in ls -dils format on standard output. |
-ok command ; | Like -exec but ask the user first. |
-okdir command ; | Like -execdir but ask the user first in the same way as for -ok. |
True; print the full file name on the standard output, followed by a newline. | |
-print0 | True; print the full file name on the standard output, followed by a null character |
-printf format | True; print format on the standard output, interpreting \' escapes and %’ directives. |
OPERATORS
UNUSUAL FILENAMES
STANDARDS CONFORMANCE
参考文献:
http://www.cnblogs.com/wanqieddy/archive/2011/06/09/2076785.html
https://blog.youkuaiyun.com/lilygg/article/details/84076757