Locate
- Usage: Locate file name
- Search by file name in background database, search faster, database is/var/lib/mlocate
- UpdateDB: Updating the database
- Search by file name only
Whereis command to search for commands
- Whereis command name #搜索命令所在路径及帮助文档所在位置
- Options
- -B Find only executable files
- -M only find help files
- Only foreign commands can be searched
Which command to search for commands
- #搜索命令所在路径及Aliases
- Only foreign commands can be searched
Find
- Find [Search Range] [search criteria] #搜索文件
- The Find/-name Install.log #避免大范围搜索, which consumes system resources #find是在系统当中搜索符合条件的文件名. If a match is required, wildcard matches are used, and wildcards are exactly matches *: matches any content? Matches any one of the characters [] matches any one of the characters in parentheses
- Find/root-iname Install.log #不区分大小写
- Find/root-user Root #按照所有者搜索
- Find/root-nouser #查找没有所有者的文件
- find/var/log/-mtime +10 #查找10天前修改的文件
- -10 #10天内修改的文件
- Ten #10天当天修改的文件
- +10 #10天前修改的文件
- Atime #文件访问时间
- CTime #改变文件属性
- Mtime #修改文件内容
Find. -size 25k #查找文件大小是25kb的文件 kb is small K, mega is capital M
- -25k #小于25kb的文件
- 25k #等于25kb的文件
- +25k #大于25kb的文件
- Find. -inum 262422 #查找i节点是262422的文件
- Find/etc-size +20k-a-size-50k-exec ls-lh {} \;
- Find files that are larger than 20kb and less than 50kb in the/etc/directory, and display more information
- #-exec/-ok command {}\; Perform action on search results
Grep
- grep [Options] string file name #在文件当中匹配符合条件的字符串
- -I ignores case
- -V excludes the specified string
The difference between the Find command and the grep command
- fing command: Search the system for eligible file names, if necessary match, wildcard match, wildcard is exactly match
- grep command: Searches the file for qualifying strings, matches with regular expressions if required, regular expressions contain matches
File Search commands in Linux