Chinaunix首页 | 论坛 | 博客
  • 博客访问: 99936
  • 博文数量: 64
  • 博客积分: 2570
  • 博客等级: 少校
  • 技术积分: 605
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-24 11:00
文章分类

全部博文(64)

文章存档

2011年(1)

2010年(25)

2009年(38)

我的朋友

分类: LINUX

2009-12-14 11:13:09

[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) |
给主人留下些什么吧!~~