encyclopegia.org

basename

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. It first appeared in 4.4BSD. The version in GNU Core Utilities was written by David MacKenzie. The command is available for Windows as part of the GnuWin32 project and UnxUtils and is in IBM i.

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. It first appeared in 4.4BSD. The version in GNU Core Utilities was written by David MacKenzie. The command is available for Windows as part of the GnuWin32 project and UnxUtils and is in IBM i. ==Use== The Single UNIX Specification 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 /path/to/filename.ext filename.ext $ basename /path/to/ to If the suffix argument is included and matches the end of the last name, then that text is removed from the result. $ basename /path/to/filename.ext .ext filename $ basename /path/to/filename.ext xx filename.ext ==See also== ==References== ==External links==

References

  1. basename · retrieved 2026-11-23 · rev 1336331793
    Cite this reference

    MLA "basename." 2026-11-23. https://en.wikipedia.org/w/index.php?oldid=1336331793. Accessed 24 November 2026.

    Chicago "basename." 2026-11-23. https://en.wikipedia.org/w/index.php?oldid=1336331793.

    APA encyclopegia.org. (2026). basename. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1336331793

Cite this article

MLA

"basename." encyclopegia.org, 2026, https://encyclopegia.org/wiki/basename. Accessed 24 November 2026.

Chicago

"basename." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/basename.

APA

encyclopegia.org. (2026). basename. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/basename

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Claims

PredicateValueSource
definitiona shell command for extracting the last name of a file path.article body
year mentioned1987article body
CC BY-SA 4.0 · tier1-factual · https://en.wikipedia.org/w/index.php?oldid=1336331793 · 0.55 · snapshot basename-030168-74761b3392c4293c · QID Q257654

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.