Empty Contents of a Specified File Without Deleting via the Command Line
If you’re working at the command line and need to quickly empty the contents of a file, throw a greater than symbol and a space in front of the filename like so:
All content within the target file will be immediately removed without warning, leaving it blank while retaining the files existence, filename, and permissions. This is often preferable and quicker than manually deleting and recreating a file.
A good practical example is for clearing out the contents of log files, for example:
You can also use this command to create a new 0 byte file at the location, similar to using the touch command.