Sometimes you need to truncate/empty a file to zero byte length. For example, you have a big file that contains various logs and the size is too big to open it easily. Of course, you can remove this file and touch it again. But this way you will have to play with permissions and file ownership. There is a simple command that will truncate the file to zero length without affecting any permissions.
# > filename
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, eg. Apache error logs.
> filename
eg
> nohup.out
Recent Comments