Sunday, November 6, 2011

Bash trick: last command shortcut

In bash, two consecutive exclamation marks (!!) stand for 'the previous command'. One instance where this could be particularly useful is when you forget the sudo command (happens to me often):
[jorge@flamingo media]$ mkdir test
mkdir: cannot create directory `test': Permission denied
(Ah, yes, I forgot the sudo!)
[jorge@flamingo media]$ sudo !!
sudo mkdir test
Password: 

No comments:

Post a Comment