IT在线课程技术文

Linux文件查找

2016-03-06  本文已影响54人  AwesomeAshe

在linux下搜索文件只需要几行简单的命令就搞定了,不过不同的指令其功能也是不一样的,使用的时候要灵活选择。

whereis <filename>

直接从数据库查询,但是只能搜索二进制文件bin,man帮助文档,源代码文件-s

它可以用来查找指定目录下的不同文件类型,比如查找/etc下所有sh开头的文件 :

locate /etc/sh

它不只会在etc目录下查找并且会自动递归子目录进行查找

又比如查找某目录下所有jpg文件:

locate /usr/share/\*.jpg
which man
find <path> <option> <action>

比如和时间相关的一些命令:

-atime //last access time
-ctime //created time
-mtime //last edit time

-mtime 参数举例:

-mtime n    //edited the day n days ago 
-mtime +n   //edited n days ago excluding nth day
-mtime -n   //edited n days ago including nth day

-newer <file>   //edited newer than <file>

e.g.:

find ~ -mtime 0

24小时内有改动

find ~ -newer /home/user/code
上一篇下一篇

猜你喜欢

热点阅读