2020-01-01 06:45:27 +00:00
|
|
|
# which
|
|
|
|
|
|
|
|
Finds a program file.
|
|
|
|
|
|
|
|
Usage:
|
2020-01-01 07:47:25 +00:00
|
|
|
> which <application> {flags}
|
2020-01-01 06:45:27 +00:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2020-01-01 07:47:25 +00:00
|
|
|
- application: the name of the command to find the path to
|
|
|
|
|
|
|
|
## Flags
|
|
|
|
|
2020-01-01 06:45:27 +00:00
|
|
|
- --all: list all executables
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
`which` finds the location of an executable:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
/home/bob> which python
|
|
|
|
━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━
|
|
|
|
arg │ path │ builtin
|
|
|
|
────────┼─────────────────┼─────────
|
|
|
|
python │ /usr/bin/python │ No
|
|
|
|
━━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━━
|
|
|
|
/home/bob> which cargo
|
|
|
|
━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━
|
|
|
|
arg │ path │ builtin
|
|
|
|
───────┼────────────────────────────┼─────────
|
|
|
|
cargo │ /home/bob/.cargo/bin/cargo │ No
|
|
|
|
━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━
|
|
|
|
```
|
|
|
|
|
|
|
|
`which` will identify nushell commands:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
/home/bob> which ls
|
|
|
|
━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━
|
|
|
|
arg │ path │ builtin
|
|
|
|
─────┼──────────────────────────┼─────────
|
|
|
|
ls │ nushell built-in command │ Yes
|
|
|
|
━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━
|
|
|
|
/home/bob> which which
|
|
|
|
━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━
|
|
|
|
arg │ path │ builtin
|
|
|
|
───────┼──────────────────────────┼─────────
|
|
|
|
which │ nushell built-in command │ Yes
|
|
|
|
━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━
|
|
|
|
```
|
|
|
|
|
|
|
|
Passing the `all` flag identifies all instances of a command or binary
|
|
|
|
|
|
|
|
```shell
|
|
|
|
/home/bob> which ls --all
|
|
|
|
━━━┯━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━
|
|
|
|
# │ arg │ path │ builtin
|
|
|
|
───┼─────┼──────────────────────────┼─────────
|
|
|
|
0 │ ls │ nushell built-in command │ Yes
|
|
|
|
1 │ ls │ /usr/bin/ls │ No
|
|
|
|
━━━┷━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━
|
|
|
|
```
|
|
|
|
|
|
|
|
`which` will also identify local binaries
|
|
|
|
|
|
|
|
```shell
|
|
|
|
/home/bob> touch foo
|
|
|
|
/home/bob> chmod +x foo
|
|
|
|
/home/bob> which ./foo
|
|
|
|
━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━
|
|
|
|
arg │ path │ builtin
|
|
|
|
───────┼───────────────┼─────────
|
|
|
|
./foo │ /home/bob/foo │ No
|
|
|
|
━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━
|
|
|
|
```
|