FreeKB - Linux Commands basename
Linux Commands - basename

The basename command extracts the everything after the last / character in a string. In this example, just the text "Documents" will be returned.

basename /home/jeremy/Documents


basename can also be used in a shell script to print the name of the script. For example, if the script is, the following command in the script will print

echo $(basename $0)


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 4e12a in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |