Skip to main content

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

Related articles

Andrew Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...