Emacs, scripting and anything text oriented.

Get current directory name without path

Kaushal Modi

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`

If you have written a response to this, enter your response post's URL below.

Or, you can send a "comment" webmention (it's OK if you don't know what that means). When asked about your website on an IndieAuth login screen, simply type https://commentpara.de.

Markdown Support**bold**, _italics_, ~~strikethrough~~, [descr](link), `monospace`, ```LANG\nline1\nline2\n``` (Yep, multi-line code blocks too, with syntax highlighting!), auto-hyperlinking.

Webmentions #