How to use Find

Source: Internet
Author: User

Find How to use

Find Command 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.

Options:

-amin< : Finds files or directories that have been accessed at a specified time, in minutes;

-anewer< refer to a file or directory;: Finds its access time more closely to the current file or directory than the specified file or directory;

-atime<24 number of hours;: Find files or directories that have been accessed at a specified time, measured in 24 hours;

-cmin< : Finds files or directories that have been changed at the time specified;

-cnewer< refer to a file or directory > find its change time more closely to the current file or directory than the specified file or directory;

-ctime<24 number of hours;: Finds files or directories that have been changed at a specified time, measured in 24 hours;

-daystart : Calculates the time from today;

-depth : Starting from the deepest sub-directory 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 Instructions: Assuming that the return value of the Find command is true, the command is executed;

-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: The effect of this parameter is similar to specifying the "-lname" parameter, but ignores the difference in case of characters;

-iname< template style: The effect of this parameter is similar to specifying the "-name" parameter, but ignores the difference in case of characters;

-inum<inode find a file or directory that matches the specified inode number ;

-ipath< template style: The effect of this parameter is similar to specifying the "-path" parameter, but ignores the difference in case of characters;

-iregex< template style: The effect of this parameter is similar to specifying the "-regexe" parameter, but ignores the difference in case of characters;

-links< number of connections;: Find files or directories that match the specified number of hard connections ;

-iname< template style;: Specifies a string as a template style for searching for symbolic connections ;

-ls : If the return value of the Find command is ture, the file or directory name is listed to the standard output;

-maxdepth< directory level;: Set the maximum directory level;

-mindepth< directory level;: Set the minimum directory level;

-mmin< : Finds files or directories that have been changed at a specified time, in minutes;

-mount : The effect of this parameter is the same as specifying "-xdev";

-mtime<24 number of 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< refer to a file or directory;: Finds its change time more closely to the current file or directory than the specified file or directory;

-nogroup : Identifying files or directories that do not belong to the local landlord group identification code;

-noleaf : No need to consider a directory with at least two hard connections exist;

-nouser : Identify files or directories that do not belong to the local host user ID;

-ok< Execution Instructions: The effect of this parameter is similar to specifying "-exec", but before executing the instruction, the user is asked to abort the execution of the command if "y" or "Y" is answered;

-path< template style;: Specifies a string as the template style for the search directory;

-perm< the value of the permission;: Find the file or directory that matches the specified permission value;

-print : If 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 : If 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< to find files or directories that have been accessed at a specified time after a file or directory has been changed, the units are calculated on a daily basis;

-user< the name of the owner;: a file or directory for the Finder and the specified owner name;

-version or--version: Display version information;

-xdev : Confine the scope to the antecedent file system;

-xtype< file Type: The effect of this parameter is similar to specifying the "-type" parameter, except that it checks for symbolic connections.

Homework:

    1. 1. Find / var the directory owner is Root , and belong to group Mail of all documents;

[Email protected]~]# find/var/-user Root-group mail–ls

    1. 2. Find / usr The directory does not belong to Root , bin or Hadoop of all documents;

[[Email protected]~]# find/usr-not \ (-user root-o-user bin-o-user hadoop \) – LS

    1. 3. Find all files whose contents have been modified and are not root or Hadoop for the most recent week in the/etc directory;

[email protected] ~]# find/etc-mtime-7-not-user root-a-not-user Hadoop

    1. 4. Find all files on the current system that are not owned by the master or group and have been visited in the last week;

[email protected] ~]# find/\ (-nouser-o-nogroup \)-atime +7

    1. 5. find all files that are larger than 20k in the/etc directory and are of the normal file type;

[[Email protected]~]# find/etc/-size +20k-type F

    1. 6. find files in/etc directory where all users do not have permission to write;

[email protected] ~]# find/etc/-not-perm/222-ls

    1. 7. find at least one class of users who do not have permission to execute files in/etc directory;

[email protected] ~]# find/etc/-not-perm-111–ls

    1. 8. Find/etc/init.d directory, all users have execute permission, and other users have write permission files;

[email protected] ~]# find/etc/init.d/-perm-111-a-perm-002-ls


How to use 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.