commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
There is 1 alternative - vote for the best!
For when you want to flush all content from a file without removing it (hat-tip to Marc Kilgus).
The downside of output redirection is that you need permissions. So something like
won't play nicely w/ sudo. You'd need to do something like
bash -c '> file'
instead, you could go w/
sudo truncate -s0 file
Immediately make a file empty. This even works if the file is still being written to. Great for cleaning up huge log files!
If you can do better, submit your command here.
You must be signed in to comment.