Clear the contents of an existing UNIX file Max Claus Posted on Oct 30, 2013 · 1 min. read A really simple but useful tip. To clear the contents of an existing file you can override the file with another empty file. sudo cp /dev/null my_file.txt