You are not logged in.

#1 2022-12-14 15:12:13

Tx86
Member
Registered: 2021-07-24
Posts: 14

Print current directory without parent directories [SOLVED]

I'm looking for a way to print the current directory, but just the current directory.

[username@hostname Screenshots]$ pwd
/home/username/Pictures/Screenshots

I want to figure out how to just print the name of the current directory, without all of the parent directories attached to it.
I've toyed around with grep, ls, and pwd, but I can't quite figure it out.
I've poured over man pages and other forums and haven't found anything. I'm really not sure if it's even possible.
But if it is, any help or input would appreciated.

Last edited by Tx86 (2022-12-14 15:20:16)

Offline

#2 2022-12-14 15:15:07

Scimmia
Fellow
Registered: 2012-09-01
Posts: 10,018

Re: Print current directory without parent directories [SOLVED]

`basename $PWD`

Offline

#3 2022-12-14 15:19:37

Tx86
Member
Registered: 2021-07-24
Posts: 14

Re: Print current directory without parent directories [SOLVED]

Thank you, it does exactly what I want.

Offline

Board footer

Powered by FluxBB