In Bash,
`~+` is expanded to the content of `PWD`
`~-` is expanded to the content of `OLDPWD`

cd /tmp
echo You are here: ~+
echo You were here: ~-

#Bash #Shell

Follow

@YesIKnowIT
I'll never understand the use of these shortcuts... How often do you need to print PWD in the Shell and not in a script?

@rastinza @YesIKnowIT `ls $PWD/*.tar.gz` gives you a list of fully qualified pathnames that you can easily copy and paste to someone else in a chat program who might be looking to pick a few and SFTP or rsync them to their local machine, for example. Plenty of other one-off cases crop up once it's in your muscle memory. You reach for the tools that best fit your brain first, and best fit your hand second.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.