ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahz_5.4.0.1/basename.htm

87 lines
2.3 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8">
<title>basename - Return non-directory portion of path name</title>
<LINK rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</HEAD>
<body bgcolor="#FFFFFF">
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h2>basename - Return non-directory portion of path name</h2>
<strong>Synopsis</strong>
<p><strong>basename</strong> <em>string</em> [<em>suffix</em>]</p>
<p><strong>Description</strong></p>
<p>You can use <strong>basename</strong> to delete any prefix
ending with the last slash (/) character present in <em>
string</em>, and a <em>suffix</em>, if specified. The resulting
filename is written to standard output. The <em>string</em> is
processed using the following rules:</p>
<ul>
<li>If <em>string</em> consists entirely of slash characters, a
single slash character is written to standard output and processing
ends.</li>
<li>If there are any trailing slash characters in <em>string</em>,
they are removed.</li>
<li>If there are any slash characters remaining in <em>string</em>,
the prefix of <em>string</em> up to and including the last slash
character is removed.</li>
<li>If a <em>suffix</em> is specified, and is not identical to the
characters remaining in <em>string</em>, and is identical to a
suffix of the characters remaining in <em>string</em>, the suffix
is removed. Otherwise <em>string</em> is not modified. It is not an
error if <em>suffix</em> is not found in <em>string</em>.</li>
</ul>
<p><strong>Exit Status</strong></p>
<ul>
<li>0 on success</li>
<li>&gt;0 if an error occurs.</li>
</ul>
<p><strong>Related information</strong></p>
<ul>
<li><a href="dirname.htm">dirname - Return directory portion of
path name</a></li>
</ul>
<strong>Examples</strong>
<ol>
<li>Set the shell variable FOO to "trail".
<pre>
FOO=$(basename /usr/bin/trail)
</pre>
</li>
<li>Return the last part of the path "/usr/bin/this_test" with the
"test" suffix removed.
<pre>
basename /usr/bin/this_test test
</pre>
</li>
</ol>
<!-- end ibmbody========================================================= -->
</body>
</html>