- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
VI中执行shell命令
vi中执行shell命令
在vi中也可以执行shell的命令。在line mode下执行指令!command, command 是 shell 命令。例如指令 !date 会把目前的时间和日期显示到屏幕上。
要是你想把 shell 命令的结果放到文件中,可以用 r !command。比如 r !date 会把现在的时间插入到游标所在行的下一行。可以指定行数,例如 20r !date 会把現在的时间放到第二十一行。
如果你想要执行一连串的的 shell命令但又不想离开vi,你可以在line mode下指令sh。这个指令会建立一个 shell,如果要离开,按【 ctrl-D 】,或者执行exit命令。
你也可以选择文档中的文字作为 shell 命令的输入。输出的结果会替换掉你输入的文字。例如 2,5!sort 会把第二列到第五列的文字依序排列,而原来的文字就会被覆盖。
实战:
#vi dosh.txt
1 Love Ain’t Wait For You
2 S Club 7
3 Your heart beats taking over
4 And theres nowhere you can go
5 And the love that you discover
6 Is finally taking hold
7 When it feels like the beginning
8 And the story will unfold
9 Theres a time to take your chances
10 Dont be scared of the unknown
11 Cause you cant fight it
12 Dont deny it
13 Love is stronger than each other
14 Show me baby
15 What youre gonna do, do
16 Love aint gonna wait for you
18 Love aint gonna wait for you
执行
:1,5!sort
1 Love Ain’t Wait For You
2 S Club 7
3 And the love that you discover
4 And theres nowhere you can go
5 Your heart beats taking over
6 Is finally taking hold
7 When it feels like the beginning
8 And the story will unfold
9 Theres a time to take your chances
10 Dont be scared of the unknown
11 Cause you cant fight it
12 Dont deny it
13 Love is stronger than each other
14 Show me baby
15 What youre gonna do, do
16 Love aint gonna wait for you
17 Dont run, dont hide
18 Love aint gonna wait for you
执行
:2r!date
1 Love Ain’t Wait For You
2 S Club 7
3 2007年07月05日 星期四 16时29分48秒 CST
4 And the love that you discover
5 And theres nowhere you can go
注:文件内容前的数组为行号(:set nu)。
holer
holeryu@
文档评论(0)