Suppose I entered the following thing into terminal:

wgets "link"

I will get the response:

No command 'wgets' found, did you mean: Command 'wget' from package 'wget' (main)

I made a mistake, and the terminal warned me.

Is there a command that I can type after the terminal warned me, so that then it will execute the command above with what it thought it was?

For example:

->wgets "link"

->No command 'wgets' found, did you mean:
 Command 'wget' from package 'wget' (main)

->yes (this command I am looking for ... is there one?)

-> executing wget "link"
  • 1
    This is not a generic "shell" question. What happens in this circumstance varies from shell to shell. The Z shell differing from the Bourne Again shell differing from the Korn shell, for example. It also depends from what shell extensions are installed. Your question is describing the behaviour of a particular shell with a particular extension. – JdeBP Jun 23 '17 at 20:39
  • I don't have much knowledge of Linux, so feel free to remove tags you don't think are valid here – K Split X Jun 23 '17 at 20:40
  • 1
    In most cases, people take advantage of the respective shells history file here. Use the Up Arrow to type a repeat of the command, remove the mistake, and continue – eyoung100 Jun 23 '17 at 20:46
  • @eyoung100 I'm aware of that, that's why I've been doing until now :P – K Split X Jun 23 '17 at 20:51
  • 3
    I think you want thefuck. ;) I wouldn't use it in Production in a million years, but it's funny. – Wildcard Jun 23 '17 at 22:19

Switch to zsh (installed by default on macOS and available as a package on all major Linux distributions, *BSD, and software collections for other Unix-like operating systems). It has autocorrect for command names.

% wgets
zsh: correct 'wgets' to 'wget' [nyae]? y
wget: missing URL
| improve this answer | |

In Bash you can use search and replace to modify the previously run incorrect command. From your example:

->wgets "link"

->No command 'wgets' found, did you mean:
 Command 'wget' from package 'wget' (main)


The wgets will be replaced with wget and the command executed.

To facilitate this on a command from earlier in the history list:


From man 3 history under Event Designators:

     Refer to the most recent command starting with string.


     Quick Substitution.  Repeat the last command, replacing string1
     with string2.  Equivalent to ''!!:s/string1/string2/''.
| improve this answer | |

As Wildcard already suggested install thefuck and then alias "yes" to it by adding the following lines to your .bash_profile, .bashrc or .zshrc:

eval $(thefuck --alias)
alias yes="fuck"
->wgets "link"

->No command 'wgets' found, did you mean:
 Command 'wget' from package 'wget' (main)


-> wget "link" [enter/↑/↓/ctrl+c]

-> Downloading...
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.