如何在cli中访问倒数第二个命令的第二个参数? [英] How can you access the second argument of the second to last command at the cli?

查看:61
本文介绍了如何在cli中访问倒数第二个命令的第二个参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

~ echo foo bar baz 
foo bar baz
~ echo catz ratz batz
catz ratz batz
~ echo !!:2 #=> ratz

在这种情况下, !!:2 访问最后一个命令的第二个参数。是否可以获取倒数第二个命令的第二个参数,在这种情况下,该参数将扩展为 bar

In this case the !!:2 accesses the second argument of the last command. Is it possible to get the second argument of the second to last command which in this case would expand to bar?

推荐答案

如@Jahid 在以前的帖子中所示

倒数第二个命令的第二个参数:

Second argument of the second to last command:

~ $ echo foo bar baz # This one is the target
foo bar baz
~ $ echo catz ratz batz
catz ratz batz
~ $ echo !-2:2
echo bar
bar

!-n 扩展到

注意:!-1 !! 相同

这篇关于如何在cli中访问倒数第二个命令的第二个参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆