How do I extract the last directory of a pwd output? I don\'t want to use any knowledge of how many levels there are in the directory structure. If I wanted to use that, I c
Should work for you: pwd | rev | cut -f1 -d'/' - | rev
pwd | rev | cut -f1 -d'/' - | rev
Reference: https://stackoverflow.com/a/31728689/663058