How can I replace ALL instances of a string in the previous command in Bash?

bash

Solution

That particular feature is called quick substitution; its documentation can be found in the Event Designators section of the Bash Manual. You can't do what you want with quick substitution; you'll have to resort to something slightly more verbose:

!!:gs/foo/bar/

Problem

If I have just entered the following command in Bash: ``` echo foo ``` I can change foo to bar by typing: ``` ^foo^bar ``` Which results in the following command being executed: ``` echo bar ``` Now if I enter: ``` echo foo foo ``` Is there a way to change both instances of foo to bar just by using the caret (`^`) operator? Additionally, are there man pages for shell operators like `^`? `man ^` results in "No manual entry for ^".

Original source

Related problems