Last Updated: February 25, 2016
·
818
· Rafael Bicalho

Three very useful command line tips

1. sudo !!
Runs the last command as root.

2. ^foo^bar
Runs the last command replacing the first occurrence of foo by bar.

3. > text.txt
Empty the file named text.txt. If the file doesn't exists, a new empty file is created.

You can check more useful tips at commandlinefu.com

3 Responses
Add your response

Important note about #2 is that it's not a global replace. See: https://coderwall.com/p/_-_cmq

over 1 year ago ·

@shawncplus I should have said this. I updated the post, thx!

over 1 year ago ·

good list, CTRL-r is also pretty handy for long commands that you typed previously (tcpdump filters, quick one-liners)

over 1 year ago ·