〖置顶〗-->要改变命运,首先要改变自己<--

shell命令--which

shell命令--which

0、which命令的专属图床

点此快速打开文章图床_shell命令which

1、which命令的功能说明

which 命令的作用是在 PATH 变量指定的路径中搜索某个系统命令的位置并且返回第一个搜索结果。也就是说使用 which 命令就可以看到某个系统命令是否存在以及执行的到底是哪一个位置的命令

2、which命令的语法格式

SYNOPSIS
    which [options] [--] programname [...]

3、which命令的选项说明

  • --version, -[vV]:显示版本信息
  • --help:显示帮助信息
  • --skip-dot:Skip directories in PATH that start with a dot.
  • --skip-tilde:Skip directories in PATH that start with a tilde.
  • --show-dot:Don't expand a dot to current directory in output.
  • --show-tilde:Output a tilde for HOME directory for non-root.
  • --tty-only:Stop processing options on the right if not on tty.
  • --all, -a:查找全部匹配的,而非第一个
  • --read-alias, -i:Read list of aliases from stdin.
  • --skip-alias:Ignore option --read-alias; don't read stdin.
  • --read-functions:Read shell functions from stdin.
  • --skip-functions:Ignore option --read-functions; don't read stdin.

4、which命令的实践操作

范例1:查看命令所在绝对路径,比如 man

which man

范例2:which 查找的目录,PATH 变量的值

echo $PATH

范例3:查找有别名的命令时会列出具体的别名信息

which which

​ 用 which 去找出 which,结果会有两个 which ,其中一个是 alias 这就是所谓的命令别名

范例4:Bash 内建一些命令无法查找到,比如 history

which history

history 这个常用的命令找不到,这是因为 historybash 内建的命令! 但是 which 默认是找 PATH 内所规范的目录,所以当然找不到!

『MineGi有话说』:快来扫一扫下面链接的二维码,加入我们吧!

posted @ 2020-02-22 08:00  MineGi  阅读(3140)  评论(0编辑  收藏  举报