Linux commands (vii) Finding files or directories find

Source: Internet
Author: User
Tags file permissions

The Find command can find the specified file or directory based on the given path strength and expression. There are many options for the find parameter, and it is powerful to support regular expressions. Combined with pipelines can achieve complex functions, which are the commands that the system management and the ordinary user must master.

One, find command format description

The path find command finds the directory paths.

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

The-exec find command executes the shell command given by this parameter to the matching file.

-ok and-exec have the same effect, but are more secure and will be prompted before each command to determine whether or not to execute.

Second, find command common parameter description

-name finds files by file name

-cpio: Use the cpio command for matching files to back up these files to a tape device

-prune to find files according to file permissions

-user Find files According to the owner of the file

-group Find files according to the group to which the files belong

-mtime-n +n to find the file at the time of the file change,-n means that the change time is less than n days, +n means change time is now N days ago

-nogroup finding files for groups that are not valid

-nouser Find Invalid owner file

-newer file1! File2 find change time than file1 new but older than file2 file

-follow if find finds a linked file, it is tracked to the file that the connection points to

-mount does not cross the file system mount point when locating files

-fstype finding files located in a file system of a type

-depth when looking for a file, first find the file in the current directory, and then look in its subdirectories

-size n finds files with a file length of n, with C indicating the length of the file in bytes

-type finding a file of a certain type

-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

-empty find blank files or directories in the system, or folders that do not have subdirectories in the directory

-false find files that are always wrong in the system

-gid n Find file with file Number group ID n in the system

-daystart test System in 24 hours from today's files, usage similar to-amin

-help Display Command Summary (HELP)

-maxdepth levels in a hierarchical directory by descending method

Third, find basic usage

Find does not add any parameters, which means finding all files and directories under the current path

Find-print printing results to standard output

Find/data/log specifying the road strength to find

Find/-name "Abc.txt" in system lookup abc.txt If execution is not found, the file does not exist in the system

Find also supports regular expression lookups

Find/data/logs-mame "*.log"-type f-printf Find files matching the specified string

Find. -name "[0-9]"-type F Find a file that starts with a number

Find/-mtime-1 |head look up files that have been modified in the system for the last 24 hours

Find/-mmin-15|head The last 15 minutes of modified files within the system

Find uses the type option to find specific file types, common types are as follows

B-Block device files

Catalog D

C-Character device files

P Pipeline File

L Symbolic Link file

F Common Files

Find. -type D finds all directories in the current path

Find. -type F Find all files in the current path

Find. -type l Find all symbolic link files in the current path

More examples will continue to be added in use .....

Iv. xargs Command

Not to be continued ....

  

  

  

Linux commands (vii) Finding files or directories 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.