DEV Community

Cover image for Bash! Bash! Bang! Bang!
Steve Latham
Steve Latham

Posted on

Bash! Bash! Bang! Bang!

The Bang Bang (!!)

What is the Bang Bang? Typing two exclamation points into your command-line and hitting your enter key with as much force as you can muster.

!! = Play the last command again, Sam.

Example:

Say you are installing an npm package globally (as you do): -

npm install -g <package_name>

Only to receive lots of permission denied errors. That’s right, you’ve forgotten to use “sudo” again, haven’t you!

You could press the up arrow and then navigate to the start of the line and type “sudo”, hit space and then meekly press the enter key.

Instead, though, you can roll out the almighty Bang Bang: -

sudo !! boom

In our example, that is equivalent to: -

sudo npm install –g <package_name>

You will eventually be using this shortcut everywhere you can.

After travelling to work only to realise you have forgotten your pass, just think -

pick up pass !!

Then, if that doesn't work, deploy the big guns: -

sudo !!

Problem solved.

Top comments (0)