This article describes how to use the find command in linux (linux file search). For more information, see LinuxFind.
Find the file MyCProgram. c in the current directory and subdirectory
# Find.-name "MyCProgram. c"
Search for files and ignore case sensitivity
# Find.-iname "MyCProgram. c"
Search for files that do not contain MyCProgram. c
Find.-maxdepth 1-not-iname "MyCProgram. c"
Search for passwd in subdirectories 3 to 5 under/
# Find/-mindepth 3-maxdepth 5-name passwd
Search and execute commands
Find.-iname "MyCProgram. c"-exec md5sum {}\;
Search for files larger than MB
# Find ~ -Size + 100 M
Search for files smaller than MB
# Find ~ -Size-100 M
Search for files equal to MB
# Find ~ -Size 100 M
Search for the maximum five files in directories and subdirectories
Find.-type f-exec ls-s {}\; | sort-n-r | head-5
Find the minimum five files in directories and subdirectories
# Find.-type f-exec ls-s {}\; | sort-n | head-5
Search for non-zero and minimum size of five files
# Find.-not-empty-type f-exec ls-s {}\; | sort-n | head-5
Search for files with write permissions for all users
# Find.-perm-g = w-type f-exec ls-l {}\;
In the/logs Directory, find and delete files whose changes were earlier than 5 days.
$ Find logs-type f-mtime + 5-exec rm {}\;
Find common files in the/var/logs directory that were modified seven days ago and ask them before deletion.
$ Find/var/logs-type f-mtime + 7-OK rm {}\;
You can use a certain file name pattern to match the file. remember to use quotation marks to cause the file name pattern. otherwise, matching and expanding will cause confusion of the find parameter.
$ Find.-name [A-Z] *-print
In the current directory, find the file with a permission of 755, that is, the file owner can read, write, and execute. other users can read and execute the file.
$ Find.-perm 755-print