Linux provides 2 powerful file/text finder Find,grep, below for a brief introduction;
Find File Lookup toolFind tool is a powerful file finder, you can use regular expressions for file lookup, the general instruction format is as follows:
1
Dir parameter: Lookup directory role parameter: function parameter pattern parameter: lookup Regular expression
Here are some common examples:
1 using regular expressions to find files
1
#根据文件名查找文件
2
Find./-name "PHP" #查找当前目录下名称为 "php" files
3
Find./-name "*php*" #查找名称中含有 "php" file
4
Find./-name "*.php" #查找以 ". Php" End of File
5
6
Find./-iname "PHP" #忽略大小写查找
7
Find./! -name "*php*" #否定查找 to find files that do not contain "PHP" in the name
2) According to the file type to find
1
Find./-type Type parameters
※ type parameter list: F: normal file D: Directory
L:link file
3) Limit file lookup depth
1
2
Find./-mindepth 2-type F # #查找深度最小为2的文件
3
4
#限制查找范围在当下目录的这一层
5
Find./-maxdepth 1-name "PHP"
4 According to file time stamp, file size lookup
1
#根据时间戳查找
2
Find./-type f-atime-7 #查找 files accessed within 7 days
3
Find./-type f-atime 7 #查找 7 days ago that day the file was accessed
4
Find./-type f-atime +7 #查找 files accessed within 7 days
5
6
Find./-type f-amin-30 #30分钟之内被访问的文件
7
8
#根据大小查找
9
Find./-type f-size-100k #查找 <100k files
10
Find./-type f-size 10M #查找 =10m files
11
Find./-type f-size +1g #查找 >1g files
grep Text Search Tool
grep is a powerful text search tool that can use regular expressions to search for text and print out matching rows, and typically grep can be used to filter out the results returned by other instructions;