The Find command for Linux

Source: Internet
Author: User

The Linux Find command searches the directory structure for files and performs the specified actions.


Find command:


1. Command format:

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


2. Command function:

Used to locate files in the file tree and make appropriate processing (possibly accessing the disk)


3. Command parameters:

1) 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.

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

3) 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 \;

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


4. Command options:650) this.width=650; "width=" 1 "height=" 1 "src="/e/u261/themes/default/images/spacer.gif "style=" text-align:center;border:1px solid RGB (221,221,221); Background-image:url ("/e/u261/themes/default/images/word.gif "); background-position:50% 50%;background-repeat:no-repeat;" alt= "Spacer.gif"/>

1)-name find files by file name.

a) find. / -name test to find the file named "Test" in the current directory

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/80/6F/wKiom1dBbeDgg_p7AAAT1iUYdeE555.png "title=" Picture 1.png "alt=" Wkiom1dbbedgg_p7aaat1iuydee555.png "/>

b) Find. -name ' test* ' find file with filename in current directory including ' Test '

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/80/6D/wKioL1dBbuyyLde6AAFEzsTrOOw607.png "title=" Picture 2.png "alt=" Wkiol1dbbuyylde6aafezstroow607.png "/>

650) this.width=650; "width=" 1 "height=" 1 "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/E /u261/themes/default/images/word.gif ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>2)-size n:[ C] Find files with a file length of n blocks, with C indicating the length of the file in bytes.

b--block (512 bytes); c--byte; w--Word (2 bytes);

k--kilobytes; m--megabytes; g--gigabytes.

a) Find ~-size +1 0 0k Find ratio 1 0 0k Large File

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/6F/wKiom1dBbg7w2ysfAAEuUrJh0HM672.png "title=" Picture 3.png "alt=" Wkiom1dbbg7w2ysfaaeuurjh0hm672.png "/>

< Span style= "font-family: ' The song body '; letter-spacing:0;font-size:16px;" >B) - 0 0k     find ratio 1 0 0k small The file

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/6F/wKiom1dBbj6ygegVAAFyU1JPKpU097.png "title=" Picture 4.png "alt=" Wkiom1dbbj6ygegvaafyu1jpkpu097.png "/>

c) Find ~-size 1 0 0k Find ratio 1 0 0k File

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/80/6D/wKioL1dBbz7SJ5eYAAALwYkWsug828.png "title=" Picture 5.png "alt=" Wkiol1dbbz7sj5eyaaalwykwsug828.png "/>

3)-prem according to file Permissions Find Files

a ) find-perm-g=w find a file with group Read permission

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/80/6D/wKioL1dBcKHSDRfJAAG88vxB7OI715.png "title=" Picture 10.png "alt=" Wkiol1dbckhsdrfjaag88vxb7oi715.png "/>

4) -type Find files 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.

a) Find .-type d Find files with file type directory

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/6F/wKiom1dBbnPiCZn8AABOJPog5-0766.png "title=" Picture 7.png "alt=" Wkiom1dbbnpiczn8aabojpog5-0766.png "/>

5) according to file Time to find

Each file in a Linux file system has three timestamps:

a ) Access Time (-atime): The last time a user accessed a file;

b modified Time (-mtime): The time the file content was last modified.

C Change Time (-ctime): The time the file metadata (metadata, such as permissions or ownership) was last changed.

-atime,-mtime,-ctime as the time parameter, the unit is day. You can use + to represent greater than,-represent less than (and the same as +,-based on file size lookups).

We're only here for-mtime example, and the other two timestamps are the same.

1.Find/-mtime +3 look for files that have been modified more than 3 days ago

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/80/6F/wKiom1dBbo6jKcblAABYVon3r40895.png "title=" Picture 8.png "alt=" Wkiom1dbbo6jkcblaabyvon3r40895.png "/>

2.find./-mtime-3FindSmallin3daysinsideModified Files

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/6D/wKioL1dBb4uCfXtXAAGXsUl1Osc214.png "title=" Picture 9.png "alt=" Wkiol1dbb4ucfxtxaagxsul1osc214.png "/>


This article is from the "Hundred Night Mikhar" blog, please be sure to keep this source http://10739720.blog.51cto.com/10729720/1775898

The Find command for Linux

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.