3

Hey fellow computer geeks,

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

cd && cd -

What does it mean?

7

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

4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.