Thursday, May 2, 2024
149
rated 0 times [  149] [ 0]  / answers: 1 / hits: 69579  / 2 Years ago, mon, may 23, 2022, 3:41:39

Is there any way to jump back to the previous working directory after doing a cd to a different directory?



My use-case is that I'm traversing a directory structure for a Java project, and I'm expecting that the current directory has only one sub-directory. So, I type cd and hit Tab and Enter rather quickly. However, the Tab failed, as I mistakenly expected one sub-directory, when in fact there are more. So now, I just executed cd, and am now in my home directory, instead of the Java project. Is there a way to "undo" this cd and jump back to the directory I was in?


More From » command-line

 Answers
4

You can use cd - to go back to your previous location, no matter where that was.


[#36807] Wednesday, May 25, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eanda

Total Points: 439
Total Questions: 116
Total Answers: 105

Location: Armenia
Member since Sat, Dec 31, 2022
1 Year ago
eanda questions
Tue, Nov 22, 22, 15:24, 1 Year ago
Sat, Oct 16, 21, 23:48, 3 Years ago
Sun, Jul 3, 22, 09:38, 2 Years ago
Thu, Feb 3, 22, 14:33, 2 Years ago
;