more cmdlines [linux-user only]
I recently learned and relearned more of common cmdlines and oneliners in bash.
Posting them gives me a place to lookup these until I enter them properly into my wiki.
linux-users follow here
copying/moving files/directories for backup:
mv originalfilename.txt{,.backup}
will result in originalfilename.txt.backup
!! will repeat the last command, usefull for adding sudo in front of it: ’sudo !!’
As for repeating the last command, you can also use the ‘^a^b’ notation. It will repeat the last command and replace the first ‘a’ with a ‘b’. Let’s see an example:
Let’s say your last command was tar xzvf somefile-version-1.16.9.tar.gz and you realized that
you should have written ‘17′ instead of ‘16′. Here’s the quickfix:
^16^17
If you look at the output of the history command, you’ll see the command-number in front of the command. You can use ‘!’ with the number:
!534
will repeat the command with the number 534.
Another usefull shortcut is <Esc> + ‘_’. This will repeat the last parameter of the last command, usefull when creating new directories and then ‘cd’ into them.