This can be done by copying the contents of an empty system file into the file to be emptied\\

<code>
true > file-to-be-emptied.txt
</code>
or
<code>
: > file-to-be-emptied.txt
</code>

More recently, this is the recommended method
<code>
: >| file-to-be-emptied.txt
</code>
The old method of\\
''cat /dev/null > file-to-be-emptied.txt''\\
is now discouraged.

Windows users take notice — when you run the command ''cat /dev/null'' Windows will throw an error. However, it will still successfully empty the contents of your file.