FreeKB - 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 foo.sh, the following command in the script will print foo.sh.

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 931cb in the box below so that we can be sure you are a human.




Comments