ANSI, make exit codes consistent
[unix-history] / usr / src / usr.bin / basename / basename.1
.\" Copyright (c) 1990 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" %sccs.include.redist.man%
.\"
.\" @(#)basename.1 6.4 (Berkeley) %G%
.\"
.Dt BASENAME 1
.Dd
.Os BSD 4.4
.Sh NAME
.Nm basename , dirname
.Nd return filename or directory portion of pathname
.Sh SYNOPSIS
.Nm basename
.Ar string
.Op Ar suffix
.Nm dirname
.Ar string
.Sh DESCRIPTION
.Nm Basename
deletes any prefix ending with the last slash
.Sq Li \&/
character present in
.Ar string ,
and a
.Ar suffix ,
if given.
The resulting filename is written to the standard output.
If
.Ar string
ends in the slash character,
.Sq Li / ,
or is the same as the
.Ar suffix
argument,
a newline is output.
A non-existant suffix is ignored.
.Pp
.Nm Dirname
deletes the filename portion, beginning
with the last slash
.Sq Li \&/
character to the end of
.Ar string ,
and writes the result to the standard output.
.Sh EXAMPLES
The following line sets the shell variable
.Ev FOO
to
.Pa /usr/bin .
.Pp
.Dl FOO=`dirname /usr/bin/trail`
.Pp
Both the
.Nm basename
and
.Nm dirname
exit 0 on success, and >0 if an error occurs.
.Sh SEE ALSO
.Xr csh 1
.Xr sh 1
.Sh STANDARDS
The
.Nm basename
and
.Nm dirname
functions are expected to be POSIX 1003.2 compatible.