SYNOPSIS
basename name [suffix]
DESCRIPTION
basename strips off the leading part of a path name, leaving only the final component of the name, which is assumed to be the file name. To accomplish this, basename first checks to see if name consists of nothing but slash (/) or backslash (\) characters. If so, basename replaces name with a single slash and the process is complete. If not, basename removes any trailing slashes. If slashes still remain, basename strips off all leading characters up to and including the final slash. Finally, if you specify suffix and the remaining portion of name contains a suffix which matches suffix, basename removes that suffix.
EXAMPLES
The command
basename src/dos/printf.c .c
produces
printf
DIAGNOSTICS
Possible exit status values are:
NOTE
basename is provided as both an external utility and a built-in MKS KornShell utility.
PORTABILITY
POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.
On Windows systems, basename strips all characters up to and including the final backslash or slash. On UNIX and POSIX-compliant systems, backslashes are valid file name characters and are not considered delimiters.
AVAILABILITY
PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
PTC MKS Toolkit 10.4 Documentation Build 39.