pushd命令使用

pushd

Save and then change the current directory. With no arguments, pushd exchanges the top two directories.

SYNTAX

pushd [dir | +N | -N] [-n]

KEY

+N Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.

-N Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.

-n Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated.

dir Makes the current working directory be the top of the stack, and then executes the equivalent of `cd dir'. cds to dir.

Related Linux Bash commands:

dirs - Display list of remembered directories
popd - Restore the previous value of the current directory saved by PUSHD

 

If your linux not have pushd command, and you OS is Redhat or Fedora Core, you can download it from here:

http://rpmfind.net/linux/rpm2html/search.php?query=perl-Sys-Pushd

 

上面是rpm包,在Redhat上直接双击安装即可,然后输入pushd看是否有这个命令。

 

pushd使用示例:

如果我希望在/usr/src和/etc/X11和/boot/grub之间切换,则可以在命令行下输入:

pushd /usr/src

pushd /etc/X11

pushd /boot/grub

然后输入dirs查看,事实上每次输入都会显示当前pushd堆栈中的内容。

可以看到显示三个路径:

/boot/grub /etc/X11 /usr/src

输入pushd,既可以在前两个路径之间相互切换。

如果想切换到最后一个(栈底)路径时 pushd +2即可。

其他详细参数看上面帮助。

 

 

最好的网络银行! 向PayPal推荐一个商家,您可获得最高为 $ 1,000.00 的奖金!
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值