1.\" $OpenBSD: which.1,v 1.12 2000/03/14 14:58:26 aaron Exp $ 2.\" 3.\" Copyright (c) 1980, 1991 Regents of the University of California. 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" from: @(#)which.1 6.3 (Berkeley) 4/23/91 35.\" 36.Dd February 21, 1997 37.Dt WHICH 1 38.Os 39.Sh NAME 40.Nm which 41.Nd "locate a program file (or files) in the path" 42.Sh SYNOPSIS 43.Nm which 44.Op Fl a 45.Ar name Op Ar ... 46.Sh DESCRIPTION 47.Nm 48takes a list of names and looks for the files which would be 49executed had these names been given as commands. 50Each argument is searched for along the user's path. 51.Pp 52If the 53.Fl a 54flag is given, 55.Nm 56will return a list of all matches instead of just the first match. 57.Pp 58The 59.Nm 60utility exits with one of the following values: 61.Pp 62.Bl -tag -width 4n -compact 63.It 0 64All names were successfully resolved. 65.It 1 66Some names were resolved but not all. 67.It 2 68No names were resolved. 69.It \-1 70A system error occurred. 71.El 72.Sh DIAGNOSTICS 73A diagnostic is given if an executable file with the argument 74name was not found in the path. 75.Sh ENVIRONMENT 76The following environment variables affect the execution of 77.Nm which : 78.Bl -tag -width PATH 79.It Ev PATH 80A colon-separated list of directories in which to find executables. 81If 82.Ev PATH 83is not set, and the given name is not a fully qualified 84or relative pathname, 85.Nm 86will fail. 87.El 88.Sh SEE ALSO 89.Xr csh 1 , 90.Xr find 1 , 91.Xr locate 1 , 92.Xr sh 1 , 93.Xr whereis 1 , 94.Xr environ 7 95.Sh HISTORY 96A 97.Nm 98command appeared in 99.Bx 3.0 . 100.Sh CAVEATS 101The 102.Nm 103command formerly was a 104.Xr csh 1 105script and could expand aliases. 106.Xr csh 1 107now has a built-in 108.Nm 109command so this version is intended for use 110with other shells like 111.Xr sh 1 . 112