Name
basename — stdin stdout - file -- opt --help --version
Synopsis
basenamepath
[suffix
]
The basename
command, given a
file path, prints the final component in the path:
➜ basename /Users/smith/finances/money.txt
money.txt
If you provide an optional suffix, it gets stripped from the result:
➜ basename /Users/smith/finances/money.txt .txt
money
basename
doesn’t care if the
file path exists: it just extracts the final filename.
Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.