If you need fast document processing system of its own needs, it can be quickly retrieved by the find command in the Linux command.
If you want to find the appropriate file in a path you can execute the following command:
find path -name filename
# Path file path, you can use / to indicate a directory, of course, can probably determine if the directory is recommended directory narrow range, so you can quickly retrieve speed; filename refers to a file to retrieve the file name.
For example: find / -name mysql.conf
# The system will traverse all the files from the root directory, and then find the output file output mysql.conf found in the console.
Of course, you can also be blurred by wildcards to specify a file name, for example, I want to find systems suffix .conf file, execute the following command:
find / -name *.conf
About the find command syntax is as follows:
find path -option [ -print ] [ -exec -ok command ] {} \
Parameter Description:
-print (optional parameter): find the matched command files to standard output.
-exec (optional parameter): find command to execute shell commands given by the parameter file match. Form of the corresponding command is 'command' {} \ ;, and attention {} \; spaces between
-ok (optional parameter): -exec and the role of the same, it will be a more secure mode to execute shell commands given by the parameter before executing each command will prompt, allowing users to confirm whether to execute.
Part find common parameters:
mount, -xdev: only checks the file and specify a directory in the same file system, avoid listing files in other file systems.
-amin n: it has been read in the last minute file n
-anewer file: the file is later than the file has been read file
-atime n: it has been read in the last n days Files
-cmin n: it has been modified in the last n minutes file
-cnewer file: file file file time than the updated file
-ctime n: been modified in the last n days Files
-empty: Empty file -gid n or -group name: gid is a group name is a name or n
-ipath p, -path p: p line with the path name of the file, ipath ignore case
-name name, -iname name: file name matches the name of the file. iname ignore case
-size n [c] # search block length n [n bytes or] file
Here are some common find command:
find ./ -type f # find files
# Find Contents
find ./ -type d
# Find the name for the file or directory file1
find ./ -name file1
# Find the name of the file in line with regular expressions, pay attention to the front of the '*' (the found files with directory)
find ./ -regex .*so.*\.gz
# Find the directory and list files in the directory (ls command separately for each directory found, when there is no option -print front line of the file list does not display the directory name)
find ./ -type d -print -exec ls {} \;
# Find the directory and list files in the directory (for each directory to find the ls command alone, we need to confirm before executing the command)
find ./ -type d -ok ls {} \;
# Find the directory and list files in the directory (the directory to find the first execution after the ls command, will be divided into multiple times when parameter is too long)
find ./ -type d -exec ls {} +
# Find the file name matching * .c files
find ./ -name \*.c
# Print test after the file name, print test documents
find ./ -name test -print -exec cat {} \;
# Test does not print the file name, print only the contents of test files
find ./ -name test -exec cat {} \;
In time within two days from now file # find files update date
find ./ -mtime -2
File in more than two days from now when the time to find the file update date #
find ./ -mtime +2
Files from the now moment of the day when more than two days # find files within updated daily
find ./ -mtime 2
Files from the current time of two minutes or less time to find the file update date #
find ./ -mmin -2
Files from the current time when more than two minutes to find the file update date #
find ./ -mmin +2
File more than one minute at a distance of less than two minutes now time to find the file update day when #
find ./ -mmin 2
# Find the file update time than the contents of the file abc update the new file
find ./ -newer abc
# Find the file access time than the file abc content updates time a new file
find ./ -anewer abc
# Find empty files or empty directories
find ./ -empty
Find and delete empty file #
find ./ -empty -type f -print -delete
Find # 644 permissions for the file or directory (to be in full compliance)
find ./ -perm 664
# Find user / group permissions to read and write, read permissions to other users (Any other rights) of files or directories
find ./ -perm -664
# Find the user has write access to a user or group has write access to the file or directory
find ./ -perm /220
find ./ -perm /u+w,g+w
find ./ -perm /u=w,g=w
# Find the owner has read access permissions to the directory or file
find ./ -perm -u=r
# Find user group permissions have read access to the file or directory
find ./ -perm -g=r
# Find the other user has read access permissions to the directory or file
find ./ -perm -o=r
# Find the owner of a file or directory is lzj
find ./ -user lzj
# Find a file or directory in the group named gname
find ./ -group gname
# Find Files user ID does not exist in the file
find ./ -nouser
Group ID # find the file does not exist in the file
find ./ -nogroup
# Find the file has execute permissions but there is no readable permissions
find ./ -executable \! -readable
Find the file or directory of the file size is greater than 10K
find ./ -size +10k
# Find the file size is less than 10k file or directory
find ./ -size -10k