1.\" Copyright (c) 1990 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)basename.1 6.4 (Berkeley) 07/24/90 7.\" 8.Dt BASENAME 1 9.Dd 10.Os BSD 4.4 11.Sh NAME 12.Nm basename , dirname 13.Nd return filename or directory portion of pathname 14.Sh SYNOPSIS 15.Nm basename 16.Ar string 17.Op Ar suffix 18.Nm dirname 19.Ar string 20.Sh DESCRIPTION 21.Nm Basename 22deletes any prefix ending with the last slash 23.Sq Li \&/ 24character present in 25.Ar string , 26and a 27.Ar suffix , 28if given. 29The resulting filename is written to the standard output. 30If 31.Ar string 32ends in the slash character, 33.Sq Li / , 34or is the same as the 35.Ar suffix 36argument, 37a newline is output. 38A non-existant suffix is ignored. 39.Pp 40.Nm Dirname 41deletes the filename portion, beginning 42with the last slash 43.Sq Li \&/ 44character to the end of 45.Ar string , 46and writes the result to the standard output. 47.Sh EXAMPLES 48The following line sets the shell variable 49.Ev FOO 50to 51.Pa /usr/bin . 52.Pp 53.Dl FOO=`dirname /usr/bin/trail` 54.Pp 55Both the 56.Nm basename 57and 58.Nm dirname 59exit 0 on success, and >0 if an error occurs. 60.Sh SEE ALSO 61.Xr csh 1 62.Xr sh 1 63.Sh STANDARDS 64The 65.Nm basename 66and 67.Nm dirname 68functions are expected to be POSIX 1003.2 compatible. 69