.\" Copyright (c) 1990 The Regents of the University of California. .\" All rights reserved. .\" .\" %sccs.include.redist.man% .\" .\" @(#)basename.1 6.3 (Berkeley) %G% .\" .Dt BASENAME 1 .Dd .Os BSD 4.4 .Sh NAME .Nm basename .Nd Extract filename from pathname .Sh SYNOPSIS .Nm basename .Ar string .Op suffix .Sh DESCRIPTION .Nm Basename strips .Ar string of its pathname prefix and a .Ar suffix , if given, to the standard output. If .Ar string ends in the slash character, .Li / , or is the same as the .Ar suffix argument, a newline is output. A non-existant suffix is ignored. .Pp The following line sets the shell variable .Ev FOO to .Pa /usr/bin . .Pp .Dl FOO=`dirname /usr/bin/trail` .Pp .Ar baseline utility exits 0 on success, and >0 if an error occurs. .Sh SEE ALSO .Xr sh 1 .Sh STANDARDS The .Nm baseline function is expected to be POSIX 1003.2 compatible.