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 are 3 alternatives - vote for the best!
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!
Using only this, has the same.
(tested in linux, HP-UX and AIX)
If you can do better, submit your command here.
You must be signed in to comment.