Rerun Bash Commands with History Expansions

Cameron Nokes
InstructorCameron Nokes

Share this video with your friends

Send Tweet

History expansions let you interact with bash's history. For example, if you forgot to run a command with sudo, you can sudo !! to rerun the last command with it. !$ can be used to access the last argument of the last command.

Alberto Maturano
Alberto Maturano
~ 6 years ago

There is an error in the transcription. It says:

[...] If I do !! sudo, you can see it runs it again. Now it works.

Should be:

[...] If I do sudo !!, you can see it runs it again. Now it works