专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

Linux中其他搜索命令(locate-which-whereis-grep)

目录

  • locate
  • which
  • whereis
  • grep

locate

解释

命令名称:locate
命令所在路径:/usr/bin/locate
执行权限:所有用户
功能描述:在文件资料库中查找文件

语法

locate [文件]
    -i 不区分大小写

提示locate命令找不到

yum -y install mlocate
updatedb

locate缺陷

1.locate不是实时的,新建的文件可能找不到,需要手动运行命令更新updatedb
2.locate无法查找/tmp文件夹下的内容,因为/tmp是临时文件夹,updatedb也不管用

示例

# 搜索文件(区分大小写)
locate test.txt

# 手动更新文件资料库
updatedb

# 搜索文件(不区分大小写)
locate -i test.txt

which

解释

命令名称:which
命令所在路径:/usr/bin/which
执行权限:所有用户
功能描述:搜索命令所在目录及别名信息

语法

which ls

示例

# 查找cp命令所在的目录及别名
which cp

[root@izm5e2q95pbpe1hh0kkwoiz ~]# which cp
alias cp='cp -i'
        /usr/bin/cp
# cp的是cp -i的别名
# cp命令的目录是/usr/bin/cp

[root@izm5e2q95pbpe1hh0kkwoiz ~]# which ls
alias ls='ls --color=auto'
        /usr/bin/ls

whereis

解释

命令名称:whereis
命令所在路径:/usr/bin/whereis
执行权限:所有用户
功能描述:搜索命令所在目录及帮助文档路径

语法

whereis ls

示例

# 查找ls命令所在的目录及帮助文档路径
whereis ls

[root@izm5e2q95pbpe1hh0kkwoiz ~]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz

# ls命令所在路径为/usr/bin/ls
# ls帮助文档的路径为/usr/share/man/man1/ls.1.gz

grep

解释

命令名称:grep
命令所在路径:/bin/grep
执行权限:所有用户
功能描述:在文件中搜寻字符串匹配的行并输出

语法

grep -v [指定字符串] [文件]
    -i 不区分大小写(insensitive)
    -v 排除指定字符串

示例

# 查找target在/etc/inittab文件中(区分大小写)
grep target /etc/inittab

[root@izm5e2q95pbpe1hh0kkwoiz ~]# grep target /etc/inittab
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
# To view current default target, run:
# To set a default target, run:
# systemctl set-default TARGET.target

## 查找target在/etc/inittab文件中(不区分大小写)
grep -i target /etc/inittab

## 在/etc/inittab文件中排除以#号开头的所有行
grep -v ^# /etc/inittab

文章永久链接:https://tech.souyunku.com/46360

未经允许不得转载:搜云库技术团队 » Linux中其他搜索命令(locate-which-whereis-grep)

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们