For details about the parameters of a linux Command (22): find command every day, refer to a linux Command (1): ls command (2): cd command http://www.bkjia.com/ OS /201210/163050.html#linuxlinuxcommand every day (3 ): pwd command Export (4): mkdir command http://www.bkjia.com/ OS /201210/1620.3.html#a linuxcommand every day (5): rm command Export (6): rmdir command http://www.bkjia.com/ OS /201210/1 64017. html; one linux Command every day (7): mv command running (8): cp command http://www.bkjia.com/ OS /201210/163164.html#a linuxcommand every day (9): touch command running (10): cat command running (11 ): nl command http://www.bkjia.com/ OS /201211/165990.htmla linuxcommand every day (12): more command http://www.bkjia.com/ OS /201211/165994.htmllinuxevery day Order (13): less command limit (14): head command limit (15): tail command limit (16): which command http://www.bkjia.com/ OS /201211/168890.htmla linuxcommand every day (17): whereis command limit (18 ): locate command http://www.bkjia.com/ OS /201211/168895.htmla linuxcommand every day (19): find Command overview example (20): find command exechttp: // www.bkjia.com/ OS /201211/168901.htmllinuxlinuxcommand (21) every day: find command xargshttp: // www.bkjia.com/ OS /201211/168903.html find some common examples of some common parameters and some specific usage and precautions. 1. Use the name option: www.2cto.com file name option is the most common option for the find command. either use this option independently or use it with other options. You can use a certain file name pattern to match the file. Remember to use quotation marks to cause the file name pattern. No matter what the current path is, if you want to find a file with a file name *. log in your root directory $ HOME, use ~ As the 'pathname' parameter, the Tilde ~ Represents your $ HOME directory. Find ~ -Name "*. log "-print: search for all '* in the current directory and subdirectory '*. log' file. You can use: find. -name "*. log "-print to search for files whose names start with an uppercase letter in the current directory and subdirectory. You can use: find. -name "[A-Z] *"-print: find/etc-name "host *"-print to find the files in the $ HOME directory, you can use: find ~ -Name "*"-print or find.-print: to enable the system to run at high load, search for all files from the root directory. Find/-name "*"-print if you want to find the file names in the current directory starting with lowercase letters, then add 4 to 9. log File: Command: find. -name "[a-z] * [4-9]. log "-print output: [root @ localhost test] # ll Total Bytes -rw-r -- r -- 1 root 302108 11-13 03 log2012.log-rw-r -- 1 root 61 11-13 03 log2013.log-rw -r -- 1 root 0 11-13 log2014.log-rw-r -- 1 root 0 11-13 06: 06 log2015.logdrwxr-xr-x 6 root 4096 10- 27 0:58 scfdrwxrwxr-x 2 root Root 4096 11-13 test3drwxrwxr-x 2 root 4096 11-13 test4 [root @ localhost test] # find. -name "[a-z] * [4-9]. log "-print. /log2014.log. /log2015.log. /test4/log2014.log [root @ localhost test] #2. perm option: Use the-perm option in File Permission mode, and search for files in File Permission mode. It is best to use the octal permission notation. For example, in the current directory, find a file with a permission of 755, that is, the file owner can read, write, and execute the file. Other users can read and execute the file. You can use: [root @ localhost test] # find. -perm 755-print .. /scf. /scf/lib. /scf/service. /scf/service/deploy. /scf/service/deploy/product. /scf/service/deploy/info. /scf/doc. /scf/bin [root @ localhost test] # Another expression: Add a horizontal bar before the octal number to indicate that all matches. For example,-007 is equivalent to 777, -005 is equivalent to 555. Command: find. -perm-005 output: [root @ localhost test] # ll Total Bytes -rw-r -- r -- 1 root 302108 11-13 03 log201 2. log-rw-r -- 1 root 61 11-13 06:03 log2013.log-rw-r -- 1 root 0 11-13 06:03 log2014.log-rw-r -- 1 root 0 11-13 log2015.logdrwxr-xr-x 6 root 4096 10-27 scfdrwxrwxr-x 2 root 4096 11-13 test3drwxrwxr-x 2 root 4096 11-13 05:50 test4 [root @ localhost test] # find. -perm-005 .. /test4./scf. /scf/lib. /scf/service. /scf/service/deploy. /scf/service/deploy/p Roduct. /scf/service/deploy/info. /scf/doc. /scf/bin. /test3 [root @ localhost test] #3. ignore a directory: If you want to ignore a directory when searching for a file because you know that there is no file in the directory, you can use the-prune option to specify the directory to be ignored. Be careful when using the-prune option, because if you use the-depth option at the same time, the-prune option will be ignored by the find command. To search for files in the test directory but not in the test/test3 directory, run the following command: find test-path "test/test3"-prune-o-print output: [root @ localhost soft] # find test-path "test/test3"-prune-o-printtesttest/log2014.logtest/log2015.logtest/test4test/test4/log2014.logtest/test4/log2013.logtest/test4/log2012.log /scftest/scf/libtest/scf/servicetest/scf/service/deploytest/scf/service/deploy/producttest/scf/service/deploy/infotest/scf/ Doctest/scf/bintest/log2013.logtest/log2012.log [root @ localhost soft] #4. how to avoid a file directory when searching for files using find: instance 1: find all files not in the test4 subdirectory in the test directory: find test-path "test/test4"-prune-o-print output: [root @ localhost soft] # find testtesttest/log2014.logtest/log2015.logtest/test4test/test4/log2014.logtest/test4/tests/test4/log2012.logtest/scftest/scf/libtest/scf/servicetest/scf/ service/deploytest/scf/service/d Eploy/producttest/scf/service/deploy/infotest/scf/doctest/scf/bintest/log2013.logtest/log2012.logtest/test3 [root @ localhost soft] # find test-path "test/test4 "-prune-o-printtesttest/log2014.logtest/log2015.logtest/scftest/scf/libtest/scf/servicetest/scf/service/deploytest/scf/service/deploy/producttest/scf/service/ deploy/infotest/scf/doctest/scf/bintest/log2013.logtest/log2012.logtest/test3 [root @ Localhost soft] # Description: find [-path ..] [expression] The short expression behind the path list is-path "test"-prune-o-print is-path "test"-a-prune-o-print. Press order evaluation, -both a and-o are short-circuit values. They are similar to shell's & | if-path "test" is true,-prune and-prune return true values, true for the logical expression; otherwise, the value-prune is not required, and the logical expression is false. If-path "test"-a-prune is false, evaluate-print,-print to return true, or the logical expression is true; otherwise, the value-print is not required, or the logical expression is true. The special expression combination can be written as: if-path "test" then-prune else-print instance 2: Avoid Multiple folders: command: find test \ (-path test/test4-o-path test/test3 \)-prune-o-print output: [root @ localhost soft] # find test \ (-path test/test4-o-path test/test3 \) -prune-o-printtesttest/log2014.logtest/log2015.logtest/scftest/scf/libtest/scf/servicetest/scf/service/deploytest/scf/service/deploy/producttest/scf/service/deploy /infotest/scf/ Doctest/scf/bintest/log2013.logtest/log2012.log [root @ localhost soft] # Note: parentheses indicate the combination of expressions. \ Indicates a reference, that is, it indicates that shell does not give a special explanation for the subsequent characters, but leaves it to the find command to explain its meaning. Instance 3: find a specific file, add-name and other options after-o command: find test \ (-path test/test4-o-path test/test3 \) -prune-o-name "*. log "-print Output: [root @ localhost soft] # find test \ (-path test/test4-o-path test/test3 \)-prune-o-name "*. log "-printtest/log2014.logtest/log2015.logtest/log2013.logtest/log2012.log [root @ localhost soft] #5. use the user and nouser options: Search for files by file owner: instance 1: find the file whose owner is peida in the $ HOME directory command: find ~ -User peida-print instance 2: find the file whose owner is peida In the/etc directory: Command: find/etc-user peida-print Description: instance 3: you can use the-nouser option to find files that have been deleted by the owner account. Find all such files in the/home directory. Command: find/home-nouser-print description: in this way, you can find the files whose owner does not have a valid account in the/etc/passwd file. When you use the-nouser option, you do not need to give a user name. The find command can complete the corresponding work for you. 6. use the group and nogroup options: like the user and nouser options, the find command also has the same options for the user group to which the file belongs, to find files belonging to the gem user group in the/apps directory, you can use: find/apps-group gem-print to find all files that do not have a valid user group. You can use the nogroup option. The following find command looks for such a file from the root directory of the file system: find/-nogroup-print7. search for files by change time or access time: if you want to search for files by change time, you can use the mtime, atime, or ctime options. If the system suddenly has no available space, it is very likely that the length of a file will increase rapidly during this period, then you can use the mtime option to find such a file. Use minus signs-to limit the files whose change time is earlier than n days ago, and use the plus sign + to limit the files whose change time is earlier than n days ago. To search for files whose modification time is less than 5 days in the root directory of the system, you can use: find/-mtime-5-print to search for files whose change time is earlier than 3 days in the/var/adm directory, you can use: find/var/adm-mtime + 3-print8. search for new or old files than a file: If you want to find all files whose change time is newer than a file but older than another file, you can use the-newer option. The general format is: newest_file_name! Oldest_file_name where ,! Is a logical non-sign. Instance 1: find the file command that is newer than the file log2012.log but earlier than the file log2017.log: find-newer log2012.log! -Newer log2017.log output: [root @ localhost test] # ll Total Bytes -rw-r -- r -- 1 root 302108 11-13 03 log2012.log-rw-r -- 1 root 61 11-13 03 log2013.log-rw -r -- 1 root 0 11-13 log2014.log-rw-r -- 1 root 0 11-13 06: 06 log2015.log-rw-r -- 1 root 0 11-16 log2016.log-rw-r -- 1 root 0 11-16 log2017.logdrwxr-xr-x 6 root 4096 10-27 0scfdrwxrwxr-x 2 root 4096 11-13 test3drwxrwxr-x 2 root 4096 11-13 test4 [root @ localhost test] # find-newer log2012.log! -Newer log2017.log .. /log2015.log. /log2017.log. /log2016.log. /test3 [root @ localhost test] # instance 2: find the new file command: find. -newer log2012.log-print Output: [root @ localhost test] # find-newer log2012.log .. /log2015.log. /log2017.log. /log2016.log. /test3 [root @ localhost test] #9. use the type option: instance 1: find all directory commands in the/etc directory: find/etc-type d-print instance 2: find all types of files except directories in the current directory. Command: find .! -Type d-print instance 3: find all symbolic link files in the/etc directory command: find/etc-type l-print10. use the size Option: you can search for a file based on the file length. The file length referred to here can be measured by block or byte. The length of a byte metering file is N c. The length of a block metering file is represented by only numbers. When searching for a file based on the file length, this file length in bytes is generally used. You can view the file system size because block metering is easier to convert. Instance 1: find a file with a length greater than 1 MB in the current directory. Command: find. -size + 000000c-print instance 2: Find a file with a length of exactly 100 bytes in the/home/apache directory: command: find/home/apache-size 100c-print instance 3: Search for files with more than 10 blocks in the current directory (one is 512 bytes) command: find. -size + 10-print11. use the depth option: when using the find command, you may want to match all files first and then search for them in the subdirectory. Use the depth option to run the find command. One reason for this is that when you use the find command to back up the file system on the tape, you want to back up all the files first, and then back up the files in the subdirectories. Instance 1: The find command starts from the root directory of the FILE system and looks for a FILE named CON. FILE. Command: find/-name "CON. FILE "-depth-print Description: it will first match all files and then go to the subdirectory to find 12. use the mount Option: find Files in the current File System (do not enter other file systems), you can use the mount option of the find command. Example 1: run the find.-name "*. XC"-mount-print command to find the file whose name ends with XC in the current directory.