I am aware of three methods to delete all entries from a file.
They are
>filename
touch filename
1filename < /dev/null
Of these three I abuse >filename
the most as that requires the least number of keystrokes.
However, I would like to know which is the most efficient of the three (if there are any more efficient methods) with respect to large log files and small files.
Also, how does the three codes operate and delete the contents?
1Edit: as discussed in this answer, this actually does not clear the file!
truncate -s 0 filename
? – Martin Thoma Jun 29 '14 at 16:18