[Zh]linux下的pushd和popd的应用
Sometimes we need change path on console frequently, and path could be more than three, for example
I work under ~/folder1, build under ~/folder2, and look at code under ~/folder3, it would be very easy to switch them if we use 'pushd'.
roro@anima:folder2$ pushd
~/temp/folder3 ~/temp/folder2 ~/temp/folder1
roro@anima:folder3$ pushd
~/temp/folder2 ~/temp/folder3 ~/temp/folder1
roro@anima:folder2$ pushd
~/temp/folder3 ~/temp/folder2 ~/temp/folder1
roro@anima:folder3$ pushd
~/temp/folder2 ~/temp/folder3 ~/temp/folder1
roro@anima:folder2$ pushd +1
~/temp/folder3 ~/temp/folder1 ~/temp/folder2
roro@anima:folder3$ pushd +2
~/temp/folder2 ~/temp/folder3 ~/temp/folder1
here, pushd will create a stack, then push down the path to it.'pushd +N' could change the folder to the 'no.N' items from stack top.
you also could pop out the path from this stack by using 'popd'
roro@anima:folder2$ popd
~/temp/folder3 ~/temp/folder1
roro@anima:folder3$ popd
~/temp/folder1
roro@anima:folder1$ popd
bash: popd: directory stack empty
阅读(460) | 评论(0) | 转发(0) |