Full Discussion (Bash Shell Tricks)

Great write-up!

Quick note, if you are using the command edit/replace feature and are using a conditional command construct (echo "first command" && echo "second command!") the ^foo^bar syntax only replaces the first instance of the searched text.

To replace every instance of that searched text, you have to use !!:gs/foo/bar; going back to my first example:

To replace all the instances of command in...

echo "first command" && echo "second command!"

...you have to execute...


...to output:

first echo
second echo!

Further reading: Stack exchange

Yup I found out about it sometime after I wrote the original post almost 10 years ago. Thanks for the reminder!

code of conduct - report abuse