Given a path get the last folder in the path

Hi,

I have a path such as:

PATH= "/home/user/Desktop/folder1/folder2"

and I want to output the last folder in the path i.e. "folder 2"

Any idea how I should do this? grep?

Thanks!

basename $PATH
1 Like