[LINUX] How to return to the previous directory with the Bash cd command

Note that I learned how to use the convenient cd command

You can use cd - to return to the previous directory.

$ pwd
/home/someuser
$ cd somewhere/to/work && pwd
/home/someuser/somewhere/to/work
$ cd -
/home/someuser
$ cd -
/home/someuser/somewhere/to/work

Useful when returning to the root directory of the original project after moving directories with npm scripts or CI/CD

$ cd path/to/child && [Do something] && cd -

Recommended Posts

How to return to the previous directory with the Bash cd command
How to delete the specified string with the sed command! !! !!
How to return to the command from the state where you can not enter interactive mode with python of git bash
Use the pushd command, which is more convenient than the cd command, to instantly return to the original directory.
How to make a command to read the configuration file with pyramid
How to get the directory where the EXE built with Pyinstaller exists
How to monitor the execution status of sqlldr with the pv command
[Linux] How to use the echo command
How to use the Linux grep command
How to use CUT command (with sample)
How to specify the NIC to scan with amazon-dash
How to try the friends-of-friends algorithm with pyfof
How to Learn Kaldi with the JUST Corpus
How to return multiple indexes with index method
How to get a list of files in the same directory with python
How to use return
How to write a GUI using the maya command
[Introduction to Python] How to iterate with the range function?
How to know the current directory in Python in Blender
How to create a submenu with the [Blender] plugin
[Reintroduction to python] How to import via the parent directory
[Python] How to specify the download location with youtube-dl
How to use python interactive mode with git bash
Linux user addition, how to use the useradd command
How to use the grep command and frequent samples
[Python] How to rewrite the table style with python-pptx [python-pptx]
(Remember quickly) How to use the LINUX command line
How to start the code written in Atom with one command without starting teminal
I tried to simulate how the infection spreads with Python
[Ubuntu] How to delete the entire contents of a directory
How to use the generator
How to update with SQLAlchemy?
How to manipulate the DOM in an iframe with Selenium
How to cast with Theano
A story about how to deal with the CORS problem
How to Alter with SQLAlchemy?
How to separate strings with','
How to get into the python development environment with Vagrant
Automatically enable virtualenv when cd to a directory with zsh
How to RDP with Fedora31
How to use the decorator
How to Delete with SQLAlchemy?
[Introduction to Python] How to get data with the listdir function
How to increase the axis
How to start the program
[For IT beginners] What to do when the rev command cannot be used with Git Bash
How to deal with the problem that the current directory moves when Python is executed from Atom
[Python] What is pip? Explain the command list and how to use it with actual examples
How to execute the sed command many times using the for statement
[sh] How to store the command execution result in a variable
[Introduction to Python] How to split a character string with the split function
How to get the ID of Type2Tag NXP NTAG213 with nfcpy
[EC2] How to install chrome and the contents of each command
[Memo] How to use BeautifulSoup4 (2) Display the article headline with Requests
[EC2] How to install and download chromedriver from the command line
How to pass arguments using an instance with systemd's systemctl command
How to output the output result of the Linux man command to a file
[Python] Explains how to use the format function with an example
[Memo] How to use BeautifulSoup4 (3) Display the article headline with class_
How to send a request to the DMM (FANZA) API with python
How to use Python with Jw_cad (Part 2 Command explanation and operation)