首页 > 系统服务 > 详细

Linux下搜索文件

时间:2016-10-17 18:25:57      阅读:207      评论:0      收藏:0      [点我收藏+]

一、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下搜索文件

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!