Unix命令行历史记录替换^ foo ^ bar(用于多次替换) [英] Unix commandline history substitution ^foo^bar (for multiple replacements)

查看:300
本文介绍了Unix命令行历史记录替换^ foo ^ bar(用于多次替换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我会使用bash命令替换上一个命令中的字符串:

Occasionally I use the bash command to replace string in previous command:

^foo^bar

今天,我想在下一行进行替换,以将所有出现的checkbox替换为`radio:

Today I wanted to make the replacement in the following line for replacing all occurrences of checkbox with `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

因此,它仅替换第一次出现的情况.如何使它替换所有出现的内容?

So it only replaces the first occurrence. How do I make it replace all occurrences?

bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.

推荐答案

man bash^old^new等同于!!:s/old/new/.您要!!:gs/old/new/全局替换.

man bash says ^old^new is equivalent to !!:s/old/new/. You want !!:gs/old/new/ to globally replace.

这篇关于Unix命令行历史记录替换^ foo ^ bar(用于多次替换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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