Linux Basic command (find)

Source: Internet
Author: User

Find command

The Find command is used to locate files under the specified directory. Any string that precedes the parameter will be treated as the name of the directory you want to find. If you use this command without setting any parameters, the Find command looks for subdirectories and files under the current directory. and displays all the subdirectories and files that are found.
Grammar
Find (options) (parameters)
Options
-amin< minutes;: Finds files or directories that have been accessed at a specified time, measured in minutes;
-anewer< reference file or directory;: Find its access time more closely to the current file or directory than the specified file or directory;
-atime<24 hours;: Finds files or directories that have been accessed at a specified time, in 24-hour terms;
-cmin< minutes;: Finds files or directories that have been changed at the specified time;
-cnewer< reference file or directory > find its change time more closely to the current file or directory than the specified file or directory;
-ctime<24 hours;: Finds files or directories that have been changed at a specified time, measured in 24 hours;
-daystart: Calculate the time from today;
-depth: Start searching from the deepest subdirectory under the specified directory;
-expty: Look for files with a file size of 0 byte, or empty directories without any subdirectories or files in the directory;
-exec< execution instruction;: If the return value of the Find command is true, execute the instruction;
-false: Sets the callback value of the Find command to false;
-fls< list file: The effect of this parameter is similar to specifying the "-ls" parameter, but saves the result as a specified list file;
-follow: Exclude symbolic connections;
-fprint< list file: The effect of this parameter is similar to specifying the "-print" parameter, but the result is saved to the specified list file;
-fprint0< list file: The effect of this parameter is similar to specifying the "-print0" parameter, but the result is saved to the specified list file;
-fprintf< list file >< output format: The effect of this parameter is similar to specifying the "-printf" parameter, but the result is saved to the specified list file;
-fstype< file system type;: Only look for files or directories under the file system type;
-gid< group identification Code;: Find files or directories that match the specified group ID;
-group< Group name: Find a file or directory that matches the specified group name;
-help or--help: online help;
-ilname< template style;: This parameter has the same effect as specifying the "-lname" parameter, but ignores the difference in the case of the character;
-iname< template style;: This parameter has the same effect as specifying the "-name" parameter, but ignores the difference in the case of the character;
-inum<inode: Find a file or directory that matches the specified inode number;
-ipath< template style;: This parameter has the same effect as specifying the "-path" parameter, but ignores the difference in the case of the character;
-iregex< template style;: This parameter has the same effect as specifying the "-regexe" parameter, but ignores the difference in the case of the character;
-links< number of connections;: Find files or directories that match the specified number of hard connections;
-iname< template style;: Specifies a string as the template style for searching for symbolic connections;
-ls: Assuming that the return value of the Find command is ture, the file or directory name is listed to the standard output;
-maxdepth< directory hierarchy;: Set the maximum directory level;
-mindepth< directory hierarchy;: Set the minimum directory level;
-mmin< minutes;: Finds files or directories that have been changed at a specified time, measured in minutes;
-mount: The effect of this parameter is the same as specifying "-xdev";
-mtime<24 hours;: Find files or directories that have been changed at a specified time, measured in 24 hours;
-name< template style;: Specifies a string as a template style for searching for a file or directory;
-newer< reference file or directory;: Find changes time more closely to the current file or directory than the specified file or directory;
-nogroup: Find files or directories that do not belong to the local landlord group identification code;
-noleaf: Do not consider the directory must have at least two hard connections exist;
-nouser: Find files or directories that do not belong to the local host user identification code;
-ok< execution instructions; the effect of this parameter is similar to specifying "-exec", but the user is asked before executing the instruction, and if "Y" or "Y" is answered, the execution of the command is discarded;
-path< template style;: Specifies the string as the template style for the search directory;
-perm< permission value;: Find the file or directory that matches the specified permission value;
-print: Assuming that the return value of the Find directive is ture, the file or directory name is listed to standard output. The format is a name for each column, with a "./" string before each name;
-print0: Assuming that the return value of the Find directive is ture, the file or directory name is listed to standard output. All names are in the same line;
-printf< output format: Assuming that the return value of the Find directive is ture, the file or directory name is listed to standard output. The format can be specified by itself;
-prune: Do not look for a string as a template to find a file or directory style;
-regex< template style;: Specifies a string as a template style for searching for a file or directory;
-size< file size;: Find files that match the specified file size;
-true: Sets the callback value of the Find command to true;
-typ< file type;: Only files that match the specified file type are found;
-uid< user identification Code;: Find a file or directory that matches the specified user ID;
-used< days;: Find files or directories that have been accessed at a specified time after a file or directory has been changed, and the units are calculated on a daily basis;
-user< name of the owner;: a file or directory with a finder and a specified owner name;
-version or--version: Displays version information;
-xdev: Confine the scope to the first file system;
-xtype< file type;: The effect of this parameter is similar to specifying the "-type" parameter, except that it checks for symbolic connections.

List all files and folders in the current directory and sub-directories
Find.
Look for filenames ending in. txt under the/home directory
*find/home-name ". txt"
Find all files ending in. txt and. pdf under the current directory and subdirectories
Find. (-name ".txt"-o-name". pdf")

Or

Find. -name ".txt"-o-name". pdf" * *

Linux Basic 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.