Linux command: cd的一些小技巧

时间长了不用都忘了, 还是记一下吧~

 

cd -          #回到上次所在目录,这个技巧我原来还真是不知道,感觉还是比较有用,省略了很多输入。

cd !$        #把上个命令的最后一个参数作为输入。

cd            #回到主目录

cd ~         #同样也是回到主目录

 

另外, 为什么!$能达到上面所述的效果呢.

原因可以Mendel Cooper的参考这个链接

Advanced Bash-Scripting Guide => An in-depth exploration of the art of shell scripting

里面这样介绍 !

!
reverse (or negate) the sense of a test or exit status [bang]. The ! operator inverts the exit status of the command to which it is applied (see Example 6-2). It also inverts the meaning of a test operator. This can, for example, change the sense of equal ( = ) to not-equal ( != ). The ! operator is a Bash keyword.

In a different context, the ! also appears in indirect variable references.

In yet another context, from the command line, the ! invokes the Bash history mechanism (see Appendix L). Note that within a script, the history mechanism is disabled.

 

关于使用!去引用bash history的详细链接如下:

里面还有!的其他用法, 需要的自行参考吧.

http://tldp.org/LDP/abs/html/abs-guide.html#HISTCOMMANDS

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值