Friday, April 11, 2008

Quickly Truncate a File

Quick shell tip:

If you want to truncate a file to zero bytes from the command-line, here's an easy way.

user@host [~]$ > filename

I used to use:

user@host [~]$ cp /dev/null filename

But the first approach is less typing.


Harshal said...

I was searching for this quite desperately. Thanks for this.

geekaycosmos said...

Thanks a lot for this tip. Very helpful.