码迷,mamicode.com
首页 > 系统相关 > 详细

Linux下搜索文件

时间:2016-10-17 18:26:48      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:搜索   linux下搜索   linux下搜索命令   

一、Linux下搜索文件的命令

  • Which 显示Linux某个命令的完整路径。加上type可以检查是内部命令还是外部命令

  • [root@linuxtest /]# which cat
    /bin/cat
    [root@linuxtest /]# type cat
    cat is hashed (/bin/cat)
    [root@linuxtest /]# type man
    man is hashed (/usr/bin/man)
    [root@linuxtest /]# type cd
    cd is a shell builtin
  • Whereis

    用于查找对应命令的位置,局限于PATH,/usr/share,man目录

  • [root@linuxtest /]# whereis cat
    cat: /bin/cat /usr/share/man/man1/cat.1.gz /usr/share/man/man1p/cat.1p.gz
  • Locate

    按名称查找文件,默认没有,需要安装,yum -y install mlocate,每天4点更新数据库updatedb,要立即生效执行updatedb;注意,它是临时的,不搜索/tmp目录

  • [root@linuxtest /]# locate tmp.txt
    /root/tmp.txt
  • Find

    Linux中比较常用而且强大的搜索命令


  • [root@linuxtest tmp]# find / -name "abc.txt" 
    /abc.txt 按名称查找
  • [root@linuxtest tmp]# find /tmp -type f/d f(文件)d(目录)
  • find /root -atime,-mtime,-ctime,(访问时间,内容修改时间,文件属性修改时间),mtime改,ctime必改
    find /root -name "tm*.txt" -mmin -60 |xargs ls -l 找到并列出时间
    find /root -name "tm*.txt" -mmin -60 -exec ls -l {}  \;与上一条效果一样


Linux下搜索文件

标签:搜索   linux下搜索   linux下搜索命令   

原文地址:http://gogoo.blog.51cto.com/543271/1862700

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!