---
name: "basename"
section: "1plan9"
platform: "linux"
package: "9base"
version: "1:6-14"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/basename/1plan9"
---

# basename(1plan9)

strip file name affixes

## NAME

basename - strip file name affixes

## SYNOPSIS

**basename** \[ **-d** \] *string* \[ *suffix* \]

## DESCRIPTION

*Basename* deletes any prefix ending in slash (**/**) and the *suffix*, if present in *string*, from *string*, and prints the result on the standard output.

The **-d** option instead prints the directory component, that is, *string* up to but not including the final slash. If the string contains no slash, a period and newline are printed.

## SOURCE

**/src/cmd/basename.c**
