Emacs, scripting and anything text oriented.

Get current directory name without path

This post shows how to get the current directory name without the preceeding path, using awk or rev+cut or the boring basename.

  • awk

    pwd | awk -F/ '{print $NF}'
    
  • rev and cut

    pwd | rev | cut -d/ -f 1 | rev
    
  • basename

    basename `pwd`
    

Comments

comments powered by Disqus