Linux: Clear contents of a file

Empty an in-use nohup.out file

cat /dev/null >nohup.out


If the file is not in use, the following works in bash

> foo.log

The command above empties out the file foo.log

If sudo is needed, truncate can be used as well

sudo truncate -s 0 foo.log

-s is the size option. 0 in this example sets the size to 0 bytes