1.\" Copyright (c) 1990, 1993, 1994 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the Institute of Electrical and Electronics Engineers, Inc. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 4. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)basename.1 8.2 (Berkeley) 4/18/94 32.\" $FreeBSD$ 33.\" 34.Dd April 18, 1994 35.Dt BASENAME 1 36.Os 37.Sh NAME 38.Nm basename , dirname 39.Nd return filename or directory portion of pathname 40.Sh SYNOPSIS 41.Nm 42.Ar string 43.Op Ar suffix 44.Nm 45.Op Fl a 46.Op Fl s Ar suffix 47.Ar string 48.Op Ar ... 49.Nm dirname 50.Ar string 51.Op Ar ... 52.Sh DESCRIPTION 53The 54.Nm 55utility deletes any prefix ending with the last slash 56.Ql \&/ 57character present in 58.Ar string 59(after first stripping trailing slashes), 60and a 61.Ar suffix , 62if given. 63The 64.Ar suffix 65is not stripped if it is identical to the remaining characters in 66.Ar string . 67The resulting filename is written to the standard output. 68A non-existent suffix is ignored. 69If 70.Fl a 71is specified, then every argument is treated as a 72.Ar string 73as if 74.Nm 75were invoked with just one argument. 76If 77.Fl s 78is specified, then the 79.Ar suffix 80is taken as its argument, and all other arguments are treated as a 81.Ar string . 82.Pp 83The 84.Nm dirname 85utility deletes the filename portion, beginning 86with the last slash 87.Ql \&/ 88character to the end of 89.Ar string 90(after first stripping trailing slashes), 91and writes the result to the standard output. 92.Sh EXIT STATUS 93.Ex -std basename dirname 94.Sh EXAMPLES 95The following line sets the shell variable 96.Ev FOO 97to 98.Pa /usr/bin . 99.Pp 100.Dl FOO=`dirname /usr/bin/trail` 101.Sh SEE ALSO 102.Xr csh 1 , 103.Xr sh 1 , 104.Xr basename 3 , 105.Xr dirname 3 106.Sh STANDARDS 107The 108.Nm 109and 110.Nm dirname 111utilities are expected to be 112.St -p1003.2 113compatible. 114