Back to the learning path

basename

basename: the base name, without the directory Command details
Step 1/1: The file name of a path

basename PATH drops the directories and keeps the file name; give a suffix and it removes that too. Handy in scripts that rename files.

$ basename /var/log/app.log .log
Fundamentalsbasename
Just the file name
Use basename to get the file name from /srv/data/summary.log, without the .log suffix.
dfNext lesson:dirname