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


nano text.txt
sudonano text.txt

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

1 Answer 1


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. Jun 12, 2018 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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