Sometimes you need to truncate a file to zero bytes. For example you have a big file that contains various logs and its size is too big to open it easily. Of course, you can revome this file and touch it again. But this way you’ll have to deal with permissions and file ownership. There is a simple command that will truncate the file to zero length without affecting any permissions. Here it is:
If the file already exists, it will be truncated to zero bytes, else this command will create an empty file. This is great for truncating big log files, e,g. Apache logs.