1

When I type sudo!! it never puts a space between sudo and anything. How do I make sudo!! add a space?

Example:

nano text.txt
sudo!!
sudonano text.txt

Maybe I am using it wrong but it never works unless I add a space after sudo.

7

You need to use

sudo !!

instead of sudo!!. This is intended behaviour. The !! history expansion, as stated in the documentation:

designates the preceding command. When you type this, the preceding command is repeated in toto.

It is simply as if !! were replaced with a find/replace with the contents of the last line. Naturally, since your line didn't start with a space, a space isn't included in the expansion.

  • xD , Ahhhaha, I feel silly now. Thanks a bunch for clarifying. – TeachMeEverything Jun 12 '18 at 14:23

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.