Empty a file via command line without deleting and recreating

This is another common administrative task I find myself needing to do on Linux or Unix machines. Typically I’ll have a log file that has grown large that I want to empty but without removing and recreating the file. This simple command does that.

cat /dev/null > filename.log