|
|
1.1 root 1: .\" Copyright (c) 1990 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted provided
5: .\" that: (1) source distributions retain this entire copyright notice and
6: .\" comment, and (2) distributions including binaries display the following
7: .\" acknowledgement: ``This product includes software developed by the
8: .\" University of California, Berkeley and its contributors'' in the
9: .\" documentation or other materials provided with the distribution and in
10: .\" all advertising materials mentioning features or use of this software.
11: .\" Neither the name of the University nor the names of its contributors may
12: .\" be used to endorse or promote products derived from this software without
13: .\" specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)basename.1 6.4 (Berkeley) 7/24/90
19: .\"
20: .Dt BASENAME 1
21: .Dd July 24, 1990
22: .Os BSD 4.4
23: .Sh NAME
24: .Nm basename , dirname
25: .Nd return filename or directory portion of pathname
26: .Sh SYNOPSIS
27: .Nm basename
28: .Ar string
29: .Op Ar suffix
30: .Nm dirname
31: .Ar string
32: .Sh DESCRIPTION
33: .Nm Basename
34: deletes any prefix ending with the last slash
35: .Sq Li \&/
36: character present in
37: .Ar string ,
38: and a
39: .Ar suffix ,
40: if given.
41: The resulting filename is written to the standard output.
42: If
43: .Ar string
44: ends in the slash character,
45: .Sq Li / ,
46: or is the same as the
47: .Ar suffix
48: argument,
49: a newline is output.
50: A non-existant suffix is ignored.
51: .Pp
52: .Nm Dirname
53: deletes the filename portion, beginning
54: with the last slash
55: .Sq Li \&/
56: character to the end of
57: .Ar string ,
58: and writes the result to the standard output.
59: .Sh EXAMPLES
60: The following line sets the shell variable
61: .Ev FOO
62: to
63: .Pa /usr/bin .
64: .Pp
65: .Dl FOO=`dirname /usr/bin/trail`
66: .Pp
67: Both the
68: .Nm basename
69: and
70: .Nm dirname
71: exit 0 on success, and >0 if an error occurs.
72: .Sh SEE ALSO
73: .Xr csh 1
74: .Xr sh 1
75: .Sh STANDARDS
76: The
77: .Nm basename
78: and
79: .Nm dirname
80: functions are expected to be POSIX 1003.2 compatible.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.