Basename
   HOME

TheInfoList



OR:

basename is a standard
computer program A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. Computer programs are one component of software, which also includes software documentation, documentation and oth ...
on
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
and
Unix-like A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s. When basename is given a pathname, it will delete any prefix up to the last slash ('/') character and return the result. basename is described in the Single UNIX Specification and is primarily used in
shell script A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file man ...
s.


History

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. It first appeared in 4.4BSD. The version of basename bundled in GNU coreutils was written by David MacKenzie. The command is available as a separate package for
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ...
as part of the
GnuWin32 The G''nu''W''in''32 project provides native ports in the form of executable computer programs, patches, and source code for various GNU and open source tools and software, much of it modified to run on the 32-bit Windows platform. The ports inc ...
project and the UnxUtils collection of
native Native may refer to: People * Jus soli, citizenship by right of birth * Indigenous peoples, peoples with a set of specific rights based on their historical ties to a particular territory ** Native Americans (disambiguation) In arts and entert ...
Win32 ports of common GNU Unix-like utilities.Native Win32 ports of some GNU utilities
/ref>


Usage

The Single UNIX Specification specification for basename is. basename string uffix :string ::A pathname :suffix ::If specified, basename will also delete the suffix.


Examples

basename will retrieve the last name from a pathname ignoring any trailing slashes $ basename /home/jsmith/base.wiki base.wiki $ basename /home/jsmith/ jsmith $ basename / / basename can also be used to remove the end of the base name, but not the complete base name $ basename /home/jsmith/base.wiki .wiki base $ basename /home/jsmith/base.wiki ki base.wi $ basename /home/jsmith/base.wiki base.wiki base.wiki


See also

* List of Unix commands *
dirname dirname is a standard computer program on Unix and Unix-like operating systems. When dirname is given a pathname, it will delete any suffix beginning with the last slash ('/') character and return the result. dirname is described in the Sing ...
* Path (computing)


References


External links

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