4 ms·
cd - (Go back to previous working directory) sudo !! (Run the last command as root) :w !sudo tee % (Save a readonly file in VIM) > tmp.file (Empty a file) c
by subbu 17y ago
cd - (Go back to previous working directory)
sudo !! (Run the last command as root)
:w !sudo tee % (Save a readonly file in VIM)
> tmp.file (Empty a file)
cmd !$ (Run cmd with previous commands arguments)
They are just some of my favorites.
- graywh 17y agoI think :w !sudo dd of=% is better. Can't remember why, though.
- kl4m 17y agoWhat is the difference with :w! ?
- jwecker 17y agomkdir -p (create a chain of directories in one call)
- avinashv 17y agoExcellent list. I use all of those except the last, which is new to me and extremely useful--so, thanks! It's now aliased. I find myself using the first two on an almost hourly basis.
- philh 17y agoThat should be cmd !*. !$ would only be the final argument to the previous command, which you can also insert with alt-. (and pressing alt-. again will cycle through final arguments to earlier commands). Adding :p to the end of a history expansion (like !$:p) will cause it not to be executed, but the expanded command line will be echoed and put in your history so you can check edit it.
- juvenn 17y agothen checkout http://www.commandlinefu.com/commands/browse/sort-by-votes http://www.commandlinefu.com/commands/browse/sort-by-votes