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