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.
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.