Empty a file from command line

On linux systems, esp. with the huge log files, I find the following command very useful. Let’s say the file that you want to truncate is site.log, enter the following command on the shell prompt and that is all to it.

> site.log

It retains the permissions etc. and just an empty file now.

Leave a Reply

Your email address will not be published. Required fields are marked *