672 xargs doesn't support -0
[illumos-gate.git] / usr / src / man / man1 / basename.1
blobac7962b4bed11acc3adba60d204e90e513870018
1 '\" te
2 .\"  Copyright 1989 AT&T  Copyright (c) 2001, Sun Microsystems, Inc.  All Rights Reserved  Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH BASENAME 1 "Mar 18, 1997"
11 .SH NAME
12 basename, dirname \- deliver portions of path names
13 .SH SYNOPSIS
14 .LP
15 .nf
16 \fB/usr/bin/basename\fR \fIstring\fR [\fIsuffix\fR]
17 .fi
19 .LP
20 .nf
21 \fB/usr/xpg4/bin/basename\fR \fIstring\fR [\fIsuffix\fR]
22 .fi
24 .LP
25 .nf
26 \fBdirname\fR \fIstring\fR
27 .fi
29 .SH DESCRIPTION
30 .sp
31 .LP
32 The \fBbasename\fR utility deletes any prefix ending in \fB/\fR and the
33 \fIsuffix\fR (if present in \fIstring\fR) from \fIstring\fR, and prints the
34 result on the standard output. It is normally used inside substitution marks
35 (\fB`\|`\fR) within shell procedures.
36 .SS "/usr/bin"
37 .sp
38 .LP
39 The \fIsuffix\fR is a pattern defined on the \fBexpr\fR(1) manual page.
40 .SS "/usr/xpg4/bin"
41 .sp
42 .LP
43 The \fIsuffix\fR is a string with no special significance attached to  any of
44 the characters it contains.
45 .sp
46 .LP
47 The \fBdirname\fR utility delivers all but the last level of the path name in
48 \fIstring\fR.
49 .SH EXAMPLES
50 .LP
51 \fBExample 1 \fRSetting environment variables
52 .sp
53 .LP
54 The following example, invoked with the argument \fB/home/sms/personal/mail\fR
55 sets the environment variable \fBNAME\fR to the file named \fBmail\fR and the
56 environment variable \fBMYMAILPATH\fR to the string  \fB/home/sms/personal\fR:
58 .sp
59 .in +2
60 .nf
61 example% \fBNAME=`basename \|$HOME/personal/mail`\fR
62 example% \fBMYMAILPATH=`dirname \|$HOME/personal/mail`\fR
63 .fi
64 .in -2
65 .sp
67 .LP
68 \fBExample 2 \fRCompiling a file and moving the output
69 .sp
70 .LP
71 This shell procedure, invoked with the argument \fB/usr/src/bin/cat.c\fR,
72 compiles the named file and moves the output to \fBcat\fR in the current
73 directory:
75 .sp
76 .in +2
77 .nf
78 example% \fBcc $1\fR
79 example% \fBmv a.out `basename $1 .c`\fR
80 .fi
81 .in -2
82 .sp
84 .SH ENVIRONMENT VARIABLES
85 .sp
86 .LP
87 See \fBenviron\fR(5) for descriptions of the following environment variables
88 that affect  the execution of \fBbasename\fR and \fBdirname\fR: \fBLANG\fR,
89 \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
90 .SH EXIT STATUS
91 .sp
92 .LP
93 The following exit values are returned:
94 .sp
95 .ne 2
96 .na
97 \fB\fB0\fR\fR
98 .ad
99 .RS 6n
100 Successful completion.
104 .ne 2
106 \fB\fB>0\fR\fR
108 .RS 6n
109 An error occurred.
112 .SH SEE ALSO
115 \fBexpr\fR(1), \fBbasename\fR(3C), \fBattributes\fR(5), \fBenviron\fR(5),
116 \fBstandards\fR(5)