Hey fellow computer geeks,

I came across this snippet of code on the Mac OS terminal:

cd && cd -

What does it mean?

2 Answers 2


cd returns to the home directory

&& lets you do something based on whether the previous command completed successfully

cd - will switch you to the previous directory


cd without arguments changes to your home directory, same as cd ~

&& lets you chain shell commands together

cd - switches back to the directory you were previously in

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .