Linux command: Find

Source: Internet
Author: User

1.find command:

Find Pathname-options [-print-exec-ok ...]

2. Usage: 

The directory path that the Pathname:find command looks for. For example, use. To represent the current directory, and/to represent the system root directory.

The-print:find command outputs the matched file to standard output.

The-exec:find command executes the shell command given by the parameter to the matching file. The corresponding command is in the form of ' command ' {} \;, note the space between {} and \;

-ok: The same as-exec, except that the shell command given by the parameter is executed in a more secure mode, prompting the user to determine whether to execute before executing each command.

-name finds files by file name.

Find. -name "*.log" finds files that end with. Log in the current directory.

-perm to find files according to file permissions.

find/opt/soft/test/-perm 777 Find a file with permission 777 in the/opt/soft/test/directory

-type Find a file of a certain type, such as:

B-block device files.

D-Directory.

C-character device file.

P-Pipeline file.

L-Symbolic link file.

F-Normal file.

-size N:[c] finds files with a file length of n blocks, with C indicating the length of the file in bytes. -n means that the file change time is now less than n days, and + n means that the file change time is now N days ago.

Find. -size +1000c find files larger than 1K in the current directory

-amin N Find the last n minutes of files accessed in the system

-atime N Find the last n*24 hour Access file in the system

-cmin n Find files in the last n minutes of the system changed file status

-ctime n Find files that have changed file status in the last n*24 hours of the system

-mmin n Find files that have changed file data in the last N minutes of the system

-mtime n Find files that have changed file data for the last n*24 hours in the system

Find-atime-2 find files that have been modified within 48 hours

3.exec:

The-exec parameter is followed by command, which terminates with a; for the end of the flag, so the semicolon behind this command is indispensable, considering that the semicolons in each system have different meanings, so precede the backslash.

{} curly braces represent the file name found in the previous find.

Find.  -type f-exec ls-l {} \; The find command matches all normal files in the current directory and lists them using the Ls-l command in the-exec option.

Find.  -name "*.log"-mtime +5-ok rm {} \; Find files that change time before n days in the directory and delete them, giving hints before deleting them

Find. -name "*.log"-exec mv {}..  \; Find files move to the specified directory

Linux command: Find

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.