Linux in the Find (search) is the most important command in the Linux system and one of the more useful commands. Find command is used to specify the parameters of the matching criteria to find the file or locate a list of files and directories. Find command can be used on a wide variety of conditions, such as permissions (rights), users (users), groups (group), file type (file type), date (date), size (size), etc. Other possible condition.
find command to find files or directories fine. The basic syntax is as follows:
find [Look] [Find conditional expression]
find common search criteria are as follows:
- -name: Search by name; the search by the name of the target file, and allows the use of "*" and wildcards; "?"
- -size: Find by file size; Fair Use "+", "-" was set more than or less than the specified size as the search condition. Common capacity units include kB (k note lowercase), MB, GB;
- -user: by file owner to find;
- -type: Search by file type; refers to an ordinary type file (f), the directory (d), a block device file (b), device file character (c) and the like.
When using multiple search criteria, logical operators may be used "-a", among the expressions "- o", respectively, and (and), or (or).
Application examples:
1, all the * .txt files in your home directory view directory Linux fans
[Linuxmi Atto Linux: ~ $] Find ~ / Linux stray / -Name * .Txt
/ Home / Linuxmi / Linux stray /LinuxMi.Com.Txt
/ Home / Linuxmi / Linux stray /Www.LinuxMi.Com.Txt
/ Home / linuxmi / Linux stray /LinuxMi.txt
2, view the home directory Linux fans all files in a directory
[linuxmi @ Linux: ~ $] the Find ~ / Linux fan / The -type f
/ Home / linuxmi / Linux fans /LinuxMi.com.txt
/ Home / linuxmi / Linux fans /LinuxMi1.py
/ Home / linuxmi / Linux fan / Linux fans micro-channel public number
/ home / linuxmi / Linux fans /linuxmi.com.jpg
/ home / linuxmi / Linux fans /www.LinuxMi.com.txt
/ home / linuxmi / Linux fans /LinuxMi3.py
/ home / linuxmi / Linux fans /Linux.zip
/ Home / linuxmi / Linux fans /LinuxMi.txt
/ Home / linuxmi / Linux fans /LinuxMi2.py
3, view the home directory Linux fans all listings directory
[Linuxmi Atto Linux: ~ $] Find ~ / Linux stray / -Type D
/ Home / Linuxmi / Linux stray /
/ Home / Linuxmi / Linux stray / LinuxMi
/ Home / Linuxmi / Linux stray / Linux stray
4, view the home directory Linux fans directory of files larger than 10k
[linuxmi @ Linux: ~ $] the Find ~ / Linux fans 10K + -size
/ home / linuxmi / Linux fan / Linux fans micro-channel public number
/ home / linuxmi / Linux fans /linuxmi.com.jpg
/ home / linuxmi / Linux fans /Linux.zip
5, view the home directory Linux fans directory of files smaller than 10k
[Linuxmi Atto Linux: ~ $] Find ~ / Linux stray -10K -Size
/ home / linuxmi / Linux stray
/ home / linuxmi / Linux stray /LinuxMi.Com.Txt
/ home / linuxmi / Linux stray /LinuxMi1.Py
/ Home / linuxmi / Linux stray /Www.LinuxMi.Com.Txt
/ Home / linuxmi / Linux stray /LinuxMi3.Py
/ Home / linuxmi / Linux stray / LinuxMi
/ Home / linuxmi / Linux stray /LinuxMi.Txt
/ Home / linuxmi / Linux stray /LinuxMi2.Py
/ Home / Linuxmi / Linux stray / Linux stray
6, view the home directory Linux fans is greater than 100M directory and named * .iso is displayed
7, Linux fans to see the home directory directory is greater than 100M or name is displayed as * .iso
[Linuxmi Atto Linux: ~ $] Find ~ / Linux stray / -Size Tasu 100M -O -Name * .Iso
/ Home / Linuxmi / Linux stray /CentOS.Iso
/ Home / Linuxmi / Linux stray /Debian.iso
8. Find / all empty directories under tmp directory.
[linuxmi@linux:~$] sudo find /tmp -type d -empty
9, to find all the empty files in the / tmp directory
[linuxmi@linux:~$] sudo find /tmp -type f -empty
/tmp/config-err-kx7ZAP
/tmp/unity_support_test.0
10, find all executable files in the home directory of fans Linux directory.
[Linuxmi Atto Linux: ~ $] Find ~ / Linux stray / -perm / a = x
11, to find the next home directory Linux fans catalog file has been modified within the scope of one day
[Linuxmi Atto Linux: ~ $] Find ~ / Linux stray / -Type F -Mtime -1
/ Home / Linuxmi / Linux stray /LinuxMi.Com.Txt
/ Home / Linuxmi / Linux stray /LinuxMi.py
12, find the directory under your home directory Linux fans iso format and size more than 100M of files and delete.
[linuxmi@linux:~] $ find ~/Linux迷/ -type f -name *.iso -size +100M -exec rm {} \;