Friday, July 02, 2010

Use Redirect Symbol to Zero File

I have mentioned this topic in an earlier post - zero'ing logfiles with cat /dev/null > logfile. But there is another easy way to zero a logfile in Bourne or Korn shell. It probably works in Bash and Zsh, too. I have to check. Here is an example below.

Note: I used the gts to represent the "greater than" or redirect symbol because blogger complained about using that particular character. Update: themadengineer reminded me on the use of "greater than" html syntax. Thanks.

Bourne Shell at the command prompt
# > mylogfile


Korn Shell at the command prompt
# > mylogfile