How to fix the last command in Bash


Sometimes we all makes mistakes. And it’s good if this is just typo in command name and we don’t erase important data. So, if it was just a typo Bash gives to us easy way to fix it!

Takes the last command, replaces string1 with string2 and executes it.


For example:

$ ehco foo bar baz
bash: ehco: command not found
$ ^ehco^echo
foo bar baz

Now we don’t need to retype all the command, or search right place to edit by the keyboard arrows – we can just replace wrong parts of commands by correct parts.