The first is to find the file name by using a-name parameter.
Query for files ending in. txt, and files that begin with T :
[Email protected]:~/test$ lsone.txt three.txt two.txt[email protected]:~/test$ Find/-name ' *.txt './two.txt ./one.txt./three.txt[email protected]:~/test$ Find./-name ' t* './two.txt./three.txt
Where./means the current directory, followed by some simple regular expressions, as in the following example, note that the regular expression needs to be enclosed in quotation marks.
[Email protected]:~/test$ touch 123.txt[email protected]:~/test$ Find/-name ' [A-z] ' * #以一个字母开头的文件./two.txt./ One.txt./three.txt[email protected]:~/test$ find./-name ' [1-9] ' *
You can find it by using a permission value , at which point you want to use the-perm parameter
[Email protected]:~/test$ ls-ltotal 0-rw-rw-r--1 ubuntu ubuntu 0 January 21:24 123.txt-rw-rw-r--1 ubuntu ubuntu 0 January c4/>20 21:18 one.txt-rw-rw-r--1 ubuntu ubuntu 0 January 21:18 three.txt-rw-rw-r--1 ubuntu ubuntu 0 January
You can also find by file type , using the-type parameter, where F represents the file, and D indicates the directory
[Email protected]:~/test$ mkdir dirone[email protected]:~/test$ ls-ltotal 4-rw-rw-r--1 ubuntu ubuntu 0 January 20 21: 123.txtdrwxrwxr-x 2 ubuntu ubuntu 4096 January 21:37 dirone-rwxrwxrwx 1 ubuntu ubuntu 0 January 21:18 one.txt-r w-rw-r--1 ubuntu ubuntu 0 January 21:18 three.txt-rw-rw-r--1 ubuntu ubuntu 0 January
Can be found based on the file creator , using the-user parameter
[Email protected]:~/test$ ls-ltotal 4-rw-rw-r--1 ubuntu ubuntu 0 January 21:24 123.txtdrwxrwxr-x 2 ubuntu Ubuntu 4 096 January 21:37 dirone-rwxrwxrwx 1 ubuntu ubuntu 0 January 21:18 one.txt-rw-r--r--1 root root 0 January 21:42 roottouch-rw-rw-r--1 ubuntu ubuntu 0 January 21:18 three.txt-rw-rw-r--1 ubuntu ubuntu 0 January
You can find it by changing the time of the file, using the-mtime parameter.
Find./-mtime-5 #查找当前目录下, files or directories changed within 5 days find./-mtime +3 #查找当前目录下, last modified 3 days ago File
Find by file size, using the-size parameter. Note that if you use a file interval, the-size parameter is prepended to each file size, similar to Mtime. Also note that 1 megabytes uses 1M, do not use 1m
[Email protected]:~/test$ ls-ltotal 8-rw-rw-r--1 ubuntu ubuntu 0 January 21:24 123.txtdrwxrwxr-x 2 ubuntu Ubuntu 4 096 January 21:37 dirone-rwxrwxrwx 1 ubuntu ubuntu 15 January 22:01 one.txt-rw-r--r--1 root root 0 January
20 21:42 roottouch-rw-rw-r--1 ubuntu ubuntu 0 January 21:18 three.txt-rw-rw-r--1 ubuntu ubuntu 0 January 20 21:18 two.txt[email protected]:~/test$ find./-size-10c #小于10字节的文件./two.txt./roottouch./three.txt./123.txt[ Email protected]:~/test$ find./-size +10c-size-20c
These parameters of find can be used in conjunction with the Xargs command, and the result can be used as input to the command after Xargs.
Shell Script--Find command for file lookup