Andrew Fletcher published: 16 March 2022 (updated) 17 March 2022 1 minute read
First off, this isn't the only method to achieve the outcome of emptying a file.
Using a symbol : is a shell built-in command that is essence equivalent to the true command and it can be used as a no-op (no operation). It can be used as follows:
# : > filename.txt
OR
# true > filename.txt
My initial file was as follows:
21548342 16 Mar 20:27 code.log
Post using the command
: > filename.txt
The response was
0 16 Mar 20:27 code.log