File Search commands in Linux

Source: Internet
Author: User

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
    1. fing command: Search the system for eligible file names, if necessary match, wildcard match, wildcard is exactly match
    2. grep command: Searches the file for qualifying strings, matches with regular expressions if required, regular expressions contain matches

File Search commands in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.