I know that pwd
will print the full path of current working directory, but I want to print only the name of the directory. Is there a simple command to do this without to parse pwd
?
Ubuntu – Bash: get current working directory name, but not full path
bashcommand line
Related Question
- Ubuntu – trim the terminal command prompt working directory
- Ubuntu – How to shorten the bash prompt’s current path to one letter per directory
- Ubuntu – a full path name
- Ubuntu – How to open file or directory in terminal without typing the full directory path
- Ubuntu – Bash scripting problem on echo -ing the current working directory
Best Answer
Yes, there is. You can use pure bash:
or better, to avoid the case when you could be in
-e
directory:(thanks to @gniourf_gniourf for the second suggestion).
Or you can use
basename
tool: