Template:Short description Template:Lowercase {{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1 | unknown = Template:Main other | preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y | AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid }}Template:Main other basename is a shell command for extracting the last name of a file path.

The command was introduced in X/Open Portability Guidelines issue 2 of 1987. It was inherited into the first version of POSIX and the Single Unix Specification.<ref>Template:Man</ref> It first appeared in 4.4BSD.<ref>Template:Man</ref> The version in GNU Core Utilities was written by David MacKenzie.<ref>Template:Man</ref> The command is available for Windows as part of the GnuWin32 project<ref>CoreUtils for Windows</ref> and UnxUtils.<ref>Native Win32 ports of some GNU utilities</ref>

UseEdit

The Single UNIX Specification is: <syntaxhighlight lang="text" class="" style="" inline="1">basename path [suffix]</syntaxhighlight>. The required argument, path, is a file path string. The second argument, which is optional, is text to remove from the end of the last name if it ends with the text.

ExamplesEdit

The command reports the last part of a path ignoring any trailing slashes.

<syntaxhighlight lang="console"> $ basename /home/jsmith/base.wiki base.wiki

$ basename /home/jsmith/ jsmith </syntaxhighlight>

If the suffix argument is included and matches the end of the last name, then that text is removed from the result.

<syntaxhighlight lang="console"> $ basename /home/jsmith/base.wiki .wiki base

$ basename /home/jsmith/base.wiki xx base.wiki </syntaxhighlight>

See alsoEdit

ReferencesEdit

Template:Reflist

External linksEdit

Template:Sister project

Template:Unix commands Template:Plan 9 commands Template:Core Utilities commands