Commit | Line | Data |
---|---|---|
9971923e | 1 | .\" @(#)basename.1 6.2 (Berkeley) %G% |
801033a1 | 2 | .\" |
e9f461a9 | 3 | .TH BASENAME 1 "" |
801033a1 KM |
4 | .AT 3 |
5 | .SH NAME | |
9971923e | 6 | basename, dirname \- strip filename affixes |
801033a1 | 7 | .SH SYNOPSIS |
9971923e KB |
8 | \fBbasename\fP \fBstring\fP [ \fBsuffix\fP ] |
9 | .br | |
10 | \fBdirname\fP \fBstring\fP | |
801033a1 | 11 | .SH DESCRIPTION |
9971923e KB |
12 | \fIBasename\fP deletes any prefix ending in `/' and the \fIsuffix\fP, |
13 | if present in \fIstring\fP, from \fIstring\fP, and prints the result | |
14 | to the standard output. It is normally used inside substitution marks | |
15 | (\`\`) in shell procedures. | |
801033a1 | 16 | .PP |
9971923e KB |
17 | \fIDirname\fP deletes from the last slash (``/'') to the end of |
18 | \fIstring\fP, and prints to result to the standard output. | |
19 | .SH EXAMPLES | |
20 | This shell procedure invoked with the argument \fI/usr/src/bin/cat.c\fP | |
21 | compiles the named file and moves the output to \fIcat\fP in the current | |
22 | directory: | |
801033a1 KM |
23 | .IP "" 15n |
24 | cc $1 | |
25 | .br | |
26 | mv a.out \`basename $1 .c\` | |
9971923e KB |
27 | .PP |
28 | The following line sets the shell variable \fIFOO\fP to \fI/usr/bin\fP. | |
29 | .IP "" 15n | |
30 | FOO=`dirname /usr/bin/trail` | |
801033a1 KM |
31 | .SH "SEE ALSO" |
32 | sh(1) |