Back to article
3 Excellent Command-linefus for Linux
June 28, 2010
Commandlinefu.com collects your useful command-line one liners and shares them with the rest of the world. I check it out every so often (if you're really dedicated, there are Twitter and RSS feeds), and here are some neat commands I learned recently:
:w !sudo tee %If you've opened a file in Vim and forgot that you don't have permission to edit it, you can save it anyway using this command. I regularly encounter this problem, and I wish I'd known about it before. ! indicates to Vim that the rest of the line is to be passed to the shell, and % refers to the current filename. tee writes standard input to the specified file; in this case, the vim w[rite] command is the input, and it pipes the current buffer into tee to be saved.
Read the rest of these command-line tips at Serverwatch.com