Lukap Lukap - 3 months ago 8
Linux Question

Take the last part of the folder path in shell

If you type pwd you get something like:

/home/username/Desctop/myfolder/


How to take the last part? The
myfolder
path.

This must be simple but I couldn't find easy solution in shell. I know how to take care of this in java but not in shell.

thanks

Answer

You're right--it's a quick command:

basename "$PWD"
Comments