2011/05/25

Empty a file

I note that most people use /dev/null to empty an existing  file such as :

#cat /dev/null > dnssec.log

Another common usage is "echo -n > dnssec.log" .

My way of clearing all content of a file is odd as I am using tail :

#tail dnssec.log > dnssec.log

Interesting, I forget how, where and when I learnt this crazy command.  Indeed, I don't quite understand  how printing some last lines of a file on screen and then pipe to the file itself can actually clear all the content.

No comments: