One linux Command every day (19): find command Overview

Source: Internet
Author: User
Tags touch command


One linux Command every day (19): find command overview link: One linux Command every day (1): ls command http://www.bkjia.com/ OS /210210/163049.html#linuxlinuxcommand every day (2): cd command Summary (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/1640 17. 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.htmllinuxcommand every day (1 3): less command running (14): head command running (15): tail command running (16): which command http://www.bkjia.com/ OS /201211/168890.htmla linuxcommand (17) every day: whereis command running (18 ): locate command http://www.bkjia.com/ OS /201211/168895.html Linux find command search file in directory structure And perform the specified operation. In Linux, the find command provides many search conditions and has powerful functions. Because find has powerful functions, there are many options, and most of them are worth the time to understand. Even if the system contains a Network File System (NFS), the find command is equally valid in the file system, and you only have the corresponding permissions. When running a find command that consumes a lot of resources, many people tend to put it in the background for execution, because it may take a long time to traverse a large file system (this is a file system with more than 30 GB bytes ). Www.2cto.com 1. command Format: find pathname-options [-print-exec-OK...] 2. command function: Used to find and process files in the file tree. 3. command Parameter: pathname: directory path searched by the find command. For example, use "." To represent the current directory, and use "/" to represent the root directory of the system. -Print: The find command outputs matching files to the standard output. -Exec: The find command executes the shell command given by this parameter on the matching file. The corresponding command is in the form of 'command' {}\;. Note the space between {} And. -OK: The Role of-exec is the same, but the shell command given by this parameter is executed in a safer mode. A prompt is displayed before each command is executed, let the user determine whether to execute. 4. Command Option: www.2cto.com-name searches for files by file name. -Perm searches for files based on the file permissions. -Prune uses this option to make the find command not to be searched in the specified directory. If the-depth option is used at the same time,-prune will be ignored by the find command. -The user searches for files based on the file owner. -The group searches for files based on the group to which the files belong. -Mtime-n + n: Find the file based on the file change time.-n indicates that the file change time is earlier than n days, and + n indicates that the file change time is earlier than n days. The find command also has the-atime and-ctime options, but they both have the-m time options. -Nogroup: Find the file with no valid group, that is, the group to which the file belongs does not exist in/etc/groups. -Nouser: Find the file without a valid owner, that is, the owner of the file does not exist in/etc/passwd. -Newer file1! File2 searches for files whose change time is newer than file1 but older than file2. -Type: search for a certain type of files, such as B-block device files. D-directory. C-character device file. P-MPs queue file. L-Symbolic Link file. F-common file. -Size n: [c] searches for files with a length of n blocks. If a file contains c, the file length is measured in bytes. -Depth: when searching for a file, first find the file in the current directory and then find it in its subdirectory. -Fstype: searches for files in a certain type of file system. These file system types can usually be found in the configuration file/etc/fstab, this configuration file contains information about the file system in the system. -Mount: the mount point of the file system is not crossed during file search. -Follow: If the find command encounters a symbolic link file, it will trace the file to which the link points. -Cpio: Use the cpio command to back up the files to the tape device. In addition, the following three differences: -amin n: Find the files accessed in the last N minutes in the system.-atime n: Find the files accessed in the last n * 24 hours in the system.-cmin n: Find the files whose status is changed in the last N minutes in the system. file-ctime n find the file whose status has changed in the last n * 24 hours in the system-mmin n find the file whose data has been changed in the last N minutes in the system-mtime n find the last file in the system files whose file data is changed in n * 24 hours 5. use instance: instance 1: find the file that has been modified within the specified time. Command: find-atime-2 output: [root @ peidachang ~] # Find-atime-2 .. /logs/monitor. /. bashrc. /. bash_profile. /. bash_history Description: an instance of a file that has been modified within 48 hours. 2. Search for the file by keyword. Command: find. -name "*. log "output: [root @ localhost test] # find. -name "*. log ". /log_link.log. /log2014.log. /test4/log3-2.log. /test4/log3-3.log. /test4/log3-1.log. /log2013.log. /log2012.log. /log. log. /test5/log5-2.log. /test5/log5-3.log. /test5/log. log. /test5/log5-1.log. /test5/test3/log3-2.log. /test5/test3/log3-3.lo G./test5/test3/log3-1.log./test3/log3-2.log./test3/log3-3.log./test3/log3-1.log Description: Find the file ending with. log in the current directory. ". "Indicates the current directory instance 3: find the file command according to the directory or file permissions: find/opt/soft/test/-perm 777 output: [root @ localhost test] # find/opt/soft/test/-perm 777/opt/soft/test/log_link.log/opt/soft/test/test4/opt/soft/test /test5/test3/opt/soft/test/test3 description: find the file instance with the permission of 777 in the/opt/soft/test/directory 4: find by Type COMMAND: find. -type f-name "*. log "output: [root @ localhost test] # find. -type f-name "*. log ". /log2014.log. /test4/log3-2.log. /test4/log3-3.log. /test4/log3-1.log. /log2013.log. /log2012.log. /log. log. /test5/log5-2.log. /test5/log5-3.log. /test5/log. log. /test5/log5-1.log. /test5/test3/log3-2.log. /test5/test3/log3-3.log. /test5/test3/log3-1.log. /test3/log3-2.log. /test3/log3-3.log. /test3/log3-1.log [root @ localhost test] # Description: Find the directory,. common file instance ending with log 5: find all current directories and sort the command: find. -type d | sort output: [root @ localhost test] # find. -type d | sort .. /scf. /scf/bin. /scf/doc. /scf/lib. /scf/service. /scf/service/deploy. /scf/service/deploy/info. /scf/service/deploy/product. /test3./test4./test5./test5/test3 [root @ localhost test] # instance 6: find Files by SIZE command: find. -size + 1000c-print Output: [root @ localhost test] # find. -size + 1000c-print .. /test4./scf. /scf/lib. /scf/service. /scf/service/deploy. /scf/service/deploy/product. /scf/service/deploy/info. /scf/doc. /scf/bin. /log2012.log. /test5./test5/test3./test3 [root @ localhost test] # Description: Find files with the current directory greater than 1 K

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.