linux command to clear data in a file code example Example 1: bash command to empty textfile : > file.log Example 2: how to empty text file in unix echo > test.txt