HOME

TheInfoList



OR:

basename is a
shell Shell may refer to: Architecture and design * Shell (structure), a thin structure ** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses Science Biology * Seashell, a hard outer layer of a marine ani ...
command Command may refer to: Computing * Command (computing), a statement in a computer language * command (Unix), a Unix command * COMMAND.COM, the default operating system shell and command-line interpreter for DOS * Command key, a modifier key on A ...
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 The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
and the
Single Unix Specification The Single UNIX Specification (SUS) is a standard for computer operating systems, compliance with which is required to qualify for using the "UNIX" trademark. The standard specifies programming interfaces for the C language, a command-line shell, ...
. It first appeared in 4.4BSD. The version in
GNU Core Utilities The GNU Core Utilities or coreutils is a collection of GNU software that implements many standard, Unix-based shell commands. The utilities generally provide POSIX compliant interface when the environment variable is set, but otherwise offers ...
was written by David MacKenzie. The command is available for
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
as part of the GnuWin32 project and
UnxUtils UnxUtils is a collection of utility programs that provide popular Unix-based shell commands ported from GNU implementations as native Windows programs that depend only on Win32 and the Microsoft C- runtime ( msvcrt.dll). The collection wa ...
.Native Win32 ports of some GNU utilities
/ref>


Use

The
Single UNIX Specification The Single UNIX Specification (SUS) is a standard for computer operating systems, compliance with which is required to qualify for using the "UNIX" trademark. The standard specifies programming interfaces for the C language, a command-line shell, ...
is: . 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.


Examples

The command reports the last part of a path ignoring any trailing slashes. $ basename /home/jsmith/base.wiki base.wiki $ basename /home/jsmith/ jsmith If the suffix argument is included and matches the end of the last name, then that text is removed from the result. $ basename /home/jsmith/base.wiki .wiki base $ basename /home/jsmith/base.wiki xx base.wiki


See also

* *


References


External links

* * * * * {{Core Utilities commands Basename Unix SUS2008 utilities Plan 9 commands Inferno (operating system) commands IBM i Qshell commands