You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.2 KiB

6 years ago
# **which**
6 years ago
6 years ago
## 说明
6 years ago
5 years ago
**which命令** 用于查找并显示给定命令的绝对路径环境变量PATH中保存了查找命令时需要遍历的目录。which指令会在环境变量$PATH设置的目录里
查找符合条件的文件。也就是说使用which命令就可以看到某个系统命令是否存在以及执行的到底是哪一个位置的命令
6 years ago
6 years ago
6 years ago
5 years ago
```markdown
6 years ago
--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 输出所有在PATH匹配的可执行文件
--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
6 years ago
```
6 years ago
## 实例
6 years ago
5 years ago
```bash
# 说明which是根据使用者所配置的 PATH 变量内的目录去搜寻可运行档的所以不同的PATH配置内容所找到的命令不一样
6 years ago
6 years ago
which cd # 用 which 去找出 cd
5 years ago
6 years ago
```