When you want to move the directory with the cd command and return to the original directory, it's almost annoying to type something like cd ../ hoge ...
In such a case, knowing the pushd command and popd command as a set is convenient because you can instantly return to the original directory.
If you want to move from directory ~ / user / dir1 to directory ~ / user / dir2, use the pushd command in the same way as the cd command.
~/user/dir1$ pushd ~/user/dir2
~/user/dir2 ~/user/dir1
You have moved to the directory ~ / user / dir2.
~/user/dir2$
Up to this point, it is the same as the cd command.
Now use the popd command to return to the original directory ~ / user / dir1.
Just hit popd.
~/user/dir2$ popd
~/user/dir1
In an instant I returned to the directory ~ / user / dir1.
~/user/dir1$
The pushd and popd commands are mainly used on the command line and in the bush-only environment and cannot be used on FreeBSD or Solairs.
I've been using the cd command to move directories all the time, so I tend to just use the cd command, but from now on I'll switch to the pushd command.
Recommended Posts