1 This is which.info, produced by makeinfo version 5.2 from which.texi.
3 INFO-DIR-SECTION System administration
5 * Which: (which). Show full path of commands.
9 This file documents 'which' version 2.x.
11 Copyright (C) 2000 - 2015, by
13 Carlo Wood, Run on IRC <carlo@alinoe.com>
14 RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
15 Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
17 Permission is granted to make and distribute verbatim copies of
18 this manual provided the copyright notice and this permission notice
19 are preserved on all copies.
22 File: which.info, Node: Top, Next: Which Program, Prev: (dir), Up: (dir)
24 'which': Show the full path of commands
25 ***************************************
27 The 'which' program shows the full path of (shell) commands.
29 This file documents 'which' version 2.21, updated 20 March 2015.
33 * Which Program:: The 'which' Program
34 * Invoking Which:: How to invoke 'which'
35 * Option Summary:: Overview of commandline options
36 * Return Value:: The return value of 'which'
37 * Example:: Examples of invokation
39 * See Also:: Related UNIX commands
43 File: which.info, Node: Which Program, Next: Invoking Which, Prev: Top, Up: Top
48 'Which' takes one or more arguments. For each of its arguments it
49 prints to stdout the full path of the executables that would have been
50 executed when this argument had been entered at the shell prompt. It
51 does this by searching for an executable or script in the directories
52 listed in the environment variable 'PATH' using the same algorithm as
56 File: which.info, Node: Invoking Which, Next: Option Summary, Prev: Which Program, Up: Top
61 The synopsis to invoke 'which' is
63 which [options] [--] programname [...]
67 * Option Summary:: Option summary
70 File: which.info, Node: Option Summary, Next: Return Value, Prev: Invoking Which, Up: Top
77 Print all matching executables in 'PATH', not just the first.
81 Read aliases from stdin, reporting matching ones on stdout. This
82 is useful in combination with using an alias for which itself. For
84 'alias which='alias | which -i''.
87 Ignore option '--read-alias', if any. This is useful to explicity
88 search for normal binaries, while using the '--read-alias' option
89 in an alias or function for which.
92 Read shell function definitions from stdin, reporting matching ones
93 on stdout. This is useful in combination with using a shell
94 function for which itself. For example:
95 'which() { declare -f | which --read-functions $@ }
99 Ignore option '--read-functions', if any. This is useful to
100 explicity search for normal binaries, while using the
101 '--read-functions' option in an alias or function for which.
104 Skip directories in 'PATH' that start with a dot.
107 Skip directories in 'PATH' that start with a tilde and executables
108 which reside in the 'HOME' directory.
111 If a directory in 'PATH' starts with a dot and a matching
112 executable was found for that path, then print "./programname"
113 rather than the full path.
116 Output a tilde when a directory matches the 'HOME' directory. This
117 option is ignored when which is invoked as root.
120 Stop processing options on the right if not on tty.
123 Print version information on standard output then exit
127 Print usage information on standard output then exit successfully.
130 File: which.info, Node: Return Value, Next: Example, Prev: Option Summary, Up: Top
135 'Which' returns the number of failed arguments, or -1 when no
136 'programname' was given.
139 File: which.info, Node: Example, Next: Bugs, Prev: Return Value, Up: Top
144 The recommended way to use this utility is by adding an alias (C shell)
145 or shell function (Bourne shell) for 'which' like the following:
151 (alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
157 alias which 'alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
159 This will print the readable ~/ and ./ when starting which from your
160 prompt, while still printing the full path when used from a script:
168 File: which.info, Node: Bugs, Next: See Also, Prev: Example, Up: Top
173 The 'HOME' directory is determined by looking for the 'HOME' environment
174 variable, which aborts when this variable doesn't exist. 'Which' will
175 consider two equivalent directories to be different when one of them
176 contains a path with a symbolic link.
179 File: which.info, Node: See Also, Next: Index, Prev: Bugs, Up: Top
187 File: which.info, Node: Index, Prev: See Also, Up: Top
195 * '--all': Option Summary. (line 6)
196 * '--help': Option Summary. (line 57)
197 * '--read-alias': Option Summary. (line 10)
198 * '--read-functions': Option Summary. (line 22)
199 * '--show-dot': Option Summary. (line 41)
200 * '--show-tilde': Option Summary. (line 46)
201 * '--skip-alias': Option Summary. (line 17)
202 * '--skip-dot': Option Summary. (line 34)
203 * '--skip-functions': Option Summary. (line 29)
204 * '--skip-tilde': Option Summary. (line 37)
205 * '--tty-only': Option Summary. (line 50)
206 * '--version': Option Summary. (line 53)
207 * '-a': Option Summary. (line 6)
208 * '-i': Option Summary. (line 10)
209 * '-v': Option Summary. (line 53)
210 * '-V': Option Summary. (line 53)
211 * aliases, handling of: Example. (line 6)
212 * Bugs, known: Bugs. (line 6)
213 * Command line Options: Option Summary. (line 6)
214 * Description of 'which': Which Program. (line 6)
215 * Examples: Example. (line 6)
216 * Invoking 'which': Invoking Which. (line 6)
217 * Options, command line: Option Summary. (line 6)
218 * Overview of command line options: Option Summary. (line 6)
219 * Return value of 'which': Return Value. (line 6)
220 * Synopsis: Invoking Which. (line 6)
226 Node: Which Program
\7f1286
227 Node: Invoking Which
\7f1778
228 Node: Option Summary
\7f2046
229 Node: Return Value
\7f3943
232 Node: See Also
\7f5227