xref: /original-bsd/usr.bin/basename/basename.1 (revision cba8738a)
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.6 (Berkeley) 03/14/91
7.\"
8.Dd
9.Dt BASENAME 1
10.Os
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.Ql \&/
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.Ql / ,
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.Ql \&/
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