首页 / LINUX / 在Linux下搜索文件
在Linux下搜索文件
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了在Linux下搜索文件,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1486字,纯文字阅读大概需要3分钟。
内容图文
在Linux下搜索文件
=============================
1,which 查找可执行文件的绝对路径
[root@aminglinux ~]# which cat
/bin/cat
[root@aminglinux ~]# which passwd
/bin/passwd
2,whereis 查找文件 //很少用
[root@aminglinux ~]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
3,locate 查找文件 //也不常用
4,使用 find搜索文件
NAME
find - search for files in a directory hierarchy(搜索目录层次结构中的文件)
常用用法:
find 目录 -mtime +n/-n 文件
find 目录 -name 文件名称
find 目录 -type 文件类型 {f,d,b,c,l,s}
find 目录 -mmin -分钟数
find 目录 -inum inode号
find 目录 -size +大小/-大小 {k,M(不能用m)}
[root@aminglinux ~]# ll -i 1.txt
33588044 -rw-r--rwx 2 alice jerry 5 6月 25 01:24 1.txt
[root@aminglinux ~]# ll -i 1.txt.hard
33588044 -rw-r--rwx 2 alice jerry 5 6月 25 01:24 1.txt.hard
[root@aminglinux ~]# find -inum 33588044
./1.txt
./1.txt.hard
[root@aminglinux ~]# find /root -type f -mmin -120
/root/.lesshst
/root/1.txt
/root/dir6/1.txt
/root/dir6/2.txt
/root/dir6/3.txt
/root/1.txt.hard
[root@aminglinux ~]# find /root -type f -mmin -120 -exec ls -l {} \;
-rw------- 1 root root 84 6月 25 02:03 /root/.lesshst
-rw-r--rwx 2 alice jerry 5 6月 25 01:24 /root/1.txt
-rw-r--r-- 1 root root 0 6月 25 01:24 /root/dir6/1.txt
-rw-r--r-- 1 root hr 0 6月 25 01:26 /root/dir6/2.txt
-rw-r--r-- 1 root root 0 6月 25 01:30 /root/dir6/3.txt
-rw-r--rwx 2 alice jerry 5 6月 25 01:24 /root/1.txt.hard
[root@aminglinux ~]# find /root -type f -mmin -90 -exec mv {} {}.bak \;
寻找root下面修改时间少于90分钟的文件,并备份。
[root@aminglinux ~]# find /root -type f -size +1k
寻找root下面大于1K的文件
原文:https://www.cnblogs.com/sambo510/p/9251791.html
内容总结
以上是互联网集市为您收集整理的在Linux下搜索文件全部内容,希望文章能够帮你解决在Linux下搜索文件所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。