Delete / truncate the entries in a file

The following command is the efficient one to delete/truncate all the entries from a file which is being actively used:

truncate -s 0 filename

Refer: http://linux.die.net/man/1/truncate

 

On the other hand, truncate would likely be slower than > filename when run from a script since running the truncate command requires the system to open the executable, load it, and the run it.

Leave a comment