Jes*_*sen 23 unix bash history
偶尔我使用bash命令替换上一个命令中的字符串:
^foo^bar
Run Code Online (Sandbox Code Playgroud)
今天我想在下面的行中替换所有出现的checkbox
`radio:
$ git mv _product_checkbox_buttons.html.erb _product_checkbox_button.html.erb
$ ^checkbox^radio
git mv _product_radio_buttons.html.erb _product_checkbox_button.html.erb
Run Code Online (Sandbox Code Playgroud)
所以它只替换第一次出现.如何更换所有出现的内容?
bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.
Run Code Online (Sandbox Code Playgroud)
dub*_*jim 32
man bash
说^old^new
相当于!!:s/old/new/
.您想要!!:gs/old/new/
全局替换.
Alo*_*hal 14
一个简单的方法是:
fc -s checkbox=radio
Run Code Online (Sandbox Code Playgroud)
我r
在我的定义中有一个别名.bashrc
:
alias r='fc -s'
Run Code Online (Sandbox Code Playgroud)
然后你想做的事情变成:
r checkbox=radio
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅我对" bash隐藏功能 "问题的回答.
归档时间: |
|
查看次数: |
6958 次 |
最近记录: |