basename
FilesFundamentals In simulator In real LinuxStrip the directory part from a path
Name: basename: the base name, without the directory
You can practise it right away in the simulator, and use it in real Linux mode too.
Description
basename strips everything up to the last / from a path, leaving the file name, and optionally a suffix too. It works on the string only and doesn't check that the file exists.
Scripts use it to get a file name from a path; in bash, ${path##*/} does the same.
Syntax
basename NAME [SUFFIX]Common options
| SUFFIX | Also remove a trailing suffix |
| -s / --suffix SUFFIX | Remove the suffix SUFFIX (works with -a) |
| -a / --multiple | Take several names, one result per line |