首页 技术 正文
技术 2022年11月10日
0 收藏 836 点赞 4,512 浏览 1988 个字

查找文件或目录

find命令示例:

  • find . -name 'Do*' 搜索当前目录(含子目录)中文件名以Do开头的文件;
  • find . -name 'Do*' -ls 搜索当前目录(含子目录)中文件名以Do开头的文件,并显示详细信息;
  • find . -type f -mmin -10 搜索当前目录(含子目录)中过去10分钟更新过的普通文件;如果不加-type f参数,则搜索普通文件、特殊文件和目录;

locate命令示例:

  • locate *.log 搜索locate命令已知的所有log结尾的文件;
  • locate ~/Do 搜索当前用户目录中以Do开头的目录及文件;
  • locate -i ~/Do 忽略大小写,搜索当前用户目录中以Do开头的目录及文件;

注意:locate命令并不能实时反映情况。

  • locate命令其实是通过搜索本地所有文件信息的缓存(/var/lib/locatedb)来反馈结果。
  • 这个缓存在系统启动时被创建,并且每天自动更新一次,所以使用locate命令无法查到最新的变动。
  • 建议在使用locate之前,先使用updatedb命令手动更新数据库。

查找文本

注意:在搜索指定开头的行和单词的使用区别。

[root@CentOS-7 ~]# ls -l
total 4
-rw-------. 1 root root 2018 Aug 30 2016 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Mar 1 2017 Desktop
drwxr-xr-x. 2 root root 6 Mar 1 2017 Documents
drwxr-xr-x. 2 root root 6 Mar 1 2017 Downloads
drwxr-xr-x. 2 root root 6 Mar 1 2017 Music
drwxr-xr-x. 2 root root 6 Mar 1 2017 Pictures
drwxr-xr-x. 2 root root 6 Mar 1 2017 Public
drwxr-xr-x. 2 root root 6 Mar 1 2017 Templates
drwxr-xr-x. 2 root root 6 Mar 1 2017 Videos
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# ls -l |grep M*
drwxr-xr-x. 2 root root 6 Mar 1 2017 Music
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# ls -l |grep ^M
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# ls -l |grep ^-rw
-rw-------. 1 root root 2018 Aug 30 2016 anaconda-ks.cfg
[root@CentOS-7 ~]#
[root@CentOS-7 ~]#

查找命令

获取命令帮助信息

  • which 显示命令的路径;
  • whereis 显示命令的路径、手册等信息(locate the binary, source, and manual page files for a command);
  • whatis 显示命令手册的页眉行,等同于man -f命令,可确认有哪些章节存在;
  • type 判断是否是内置命令,如果是外部命令将给出简要信息;

使用示例:

[root@CentOS-7 ~]# which find
/usr/bin/find
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# whereis find
find: /usr/bin/find /usr/share/man/man1/find.1.gz /usr/share/man/man1p/find.1p.gz
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# whatis find
find (1) - search for files in a directory hierarchy
find (1p) - find files
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# type find
find is hashed (/usr/bin/find)
[root@CentOS-7 ~]#
[root@CentOS-7 ~]# type cd
cd is a shell builtin
[root@CentOS-7 ~]#

查找文档

  • /usr/share/doc/目录:程序相关文档
  • /usr/share/man目录:man命令的帮助文件

Manual Page Chapter List

1:所有用户可以操作的指令或可执行文件
2:系统核心调用的函数与工具
3:子调用,常用的函数与函数库
4:设备,硬件文件说明,通常是/dev/的文件
5:文件格式,配置文件或者是某些档案的格式
6:游戏相关
7:杂项,例如linux文件系统、网络协议、ASCIIcode等说明
8:系统管理员可用的命令
9:跟kernel有关的文件
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,133
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,297