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 ^".
Replace String in a File with the `sed` Command'-i' option is used to modify the content of the original file with the replacement string if the search string exists in the file. 's' indicates the substitute command. 'search_string' contains the string value that will be searched in the file for replacement.
1) Ctrl + P This is the most dependable shortcut in Linux to execute the last run command in the terminal. Just press the Ctrl and P keys together to fill the prompt with the last executed command and you are ready to go.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With