Answers:
您可以使用该!!:gs/search/replace/符号执行所需的操作。这利用了全局搜索和替换(:gs):
之前
$ echo "harm warm swarm barm"
harm warm swarm barm
后
$ !!:gs/arm/orn/
echo "horn worn sworn born"
horn worn sworn born
[subhrcho@slc04lyo pcbpel]$ echo "hat that bat" hat that bat [subhrcho@slc04lyo pcbpel]$ !!:gs/at/xx/ echo "hxx that bat" hxx that bat。我想念什么?
bash --version= 4.2.45(1)-发布。
我不相信有一个简单的方法来添加的东西^string1^string2,使bash更换所有出现。正如slm所指出的,您必须编写!!:gs/string1/string1。
但在中zsh,您只需添加:G:
$ echo foo foo
foo foo
$ ^foo^bar^:G
echo bar bar
bar bar
在bash和中zsh,您还可以fc -s像这样使用:
$ echo foo foo
foo foo
$ fc -s foo=bar
echo bar bar
bar bar
这通常被称为别名,r因此您可以执行以下操作:
$ echo foo foo
foo foo
$ r foo=bar
echo bar bar
bar bar
我认为最好的选择是使用“:&”
$ echo "dog cat dog"
$ ^dog^cat^:&
echo "cat cat cat"
cat cat cat
:&副本数量要多得多。
command-history为此使用了标记。添加。另外,我假设您指的是bash外壳程序?