BASENAME(1) User Commands BASENAME(1)

# [NAME](#NAME)

basename - strip directory and suffix from filenames

# [SYNOPSIS](#SYNOPSIS)

**basename** *NAME* \[*SUFFIX*]  
**basename** *OPTION*... *NAME*...

# [DESCRIPTION](#DESCRIPTION)

Print NAME with any leading directory components removed. If specified, also remove a trailing SUFFIX.

Mandatory arguments to long options are mandatory for short options too.

[**-a, --multiple**](#a,)

support multiple arguments and treat each as a NAME

[**-s, --suffix=SUFFIX**](#s,)

remove a trailing SUFFIX; implies **-a**

[**-z, --zero**](#z,)

end each output line with NUL, not newline

[**--help**](#help)

display this help and exit

[**--version**](#version)

output version information and exit

# [EXAMPLES](#EXAMPLES)

[basename /usr/bin/sort](#basename)

-&gt; "sort"

[basename include/stdio.h .h](#basename~2)

-&gt; "stdio"

[basename -s .h include/stdio.h](#basename~3)

-&gt; "stdio"

[basename -a any/str1 any/str2](#basename~4)

-&gt; "str1" followed by "str2"

# [AUTHOR](#AUTHOR)

Written by David MacKenzie.

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to: &lt;bug-coreutils@gnu.org&gt;.  
Report any translation bugs to: &lt;https://translationproject.org/team/&gt;.  
GNU coreutils home page: &lt;https://www.gnu.org/software/coreutils/&gt;  
General help using GNU software: &lt;https://www.gnu.org/gethelp/&gt;

# [COPYRIGHT](#COPYRIGHT)

Copyright © 2026 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later &lt;https://gnu.org/licenses/gpl.html&gt;.  
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

# [SEE ALSO](#SEE_ALSO)

[**dirname**(1)](/man/os/coreutils/dirname.1), [**readlink**(1)](/man/os/coreutils/readlink.1)

Full documentation &lt;https://www.gnu.org/software/coreutils/basename&gt;  
or available locally via: info '(coreutils) basename invocation'

October 2026 GNU coreutils 9.12

---

Document: basename(1) from coreutils 9.12-r7 (Chainguard OS)
Source: https://git.savannah.gnu.org/git/coreutils.git
