Linux command to find files
Some files for a long time do not forget the name, only a vague impression, at this time to find the file command is particularly important! Linux provides more powerful lookup commands than Windows.
(This is just a few of the usual, so don't explain it in detail ~ ~ ~)
1. Find
Command format:
Find < Specify directory > < options > < parameters > < specify Actions >
< Specify directory >: usually the default directory
< options >< Parameters >:
-name Search by file name
-iname Search by file name, but not case-sensitive
-user Find files According to the owner of the file: Find/-user Fred//Find files belonging to Fred This user in the system
Use of-a,-o,-not:-A connection two different conditions (two conditions must be met at the same time)
#find/tmp-name "*.sh"-a-user root
-O Connection two different conditions (two conditions to satisfy one)
#find/tmp-name "*.sh"-o-user root
-not on the condition inversion
#find/tmp-not-user Root
-type find a file of a certain type: F normal file D directory
-size N[c] Find files with a file length of n blocks, with C indicating file length in bytes: #find/tmp-size 2M//Find files equal to 2M in/tmp directory
< specify Actions >:
-print//actions by default
-ls//Find and then use LS to display it
Example: Finding a file with a known part of the file name log: Find-name "*log*" (looking in the current directory)
Immediately displays the "config.py" file information on the screen after finding the "config.py" file: Find. -name "config.py"-ls
2. Locate(better than find, faster than find, it searches the database directly)
It is a good idea to update the database before you find it, which is necessary for new files, command: UpdateDB
Search all files starting with SH in the ETC directory: locate/etc/sh
Search for all files starting with M in the user's home directory: Locate ~/m
Search for all files starting with M in the user's home directory, and ignore case: Locate-i ~/m
Find makefile to do the end of the file: Locate-r makefile$
Find files that start with/var/lib/dpkg/info/: Locate-r ^/var/lib/dpkg/info/
La la la la la cheer ~ ~ ~ (today is also a happy to send several ^-^)
One step at a day: Linux commands to find files