The command cd - in Bash is used to switch back to the previous directory you were in. It acts as a toggle between your current directory and the last one you navigated from.
Example:
- Suppose you are in
/home/user/documents. - You then change to
/home/user/downloadsusing:cd /home/user/downloads - If you run:
You will return tocd -/home/user/documents.
Usage:
- This command is helpful for quickly switching back and forth between two directories without needing to type their full paths.
If you have more questions or need further clarification, feel free to ask!
