shell 搜索文件 find、locate、whereis、which、type

忘记文件所在的位置?
咱不怕!

搜索文件的命令为”find“;”locate“;”whereis“;”which“;”type“

find

最强大的搜索命令

格式:

find <指定目录> <指定条件> <指定动作>

例如:在当前目录及子目录下搜索文件名中包含‘html’字段的文件

find ./ -name '*html*'

参考:

  1. Shell中find命令查找指定文件或目录
  2. shell命令find

locate

locate比find命令快,它查询的是数据库(/var/lib/locatedb),数据库包含本地所有的文件信息。

locate '*mycode*'

whereis

可以搜索linux系统中的所有可执行文件即二进制文件。

$ whereis python
python: /user/bin/python

which

查看系统命令是否存在,并返回系统命令所在的位置。

$ which python
~/.jumbo/bin/python

type

查看系统中的某个命令是否为系统自带的命令。

$ type python
python is home/work/.jumbo/bin/python
$ type ps
ps is /bin/ps
$ type cd
cd is a shell builtin
$ type hahaha
bash: type: hahaha: not found
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值