I have a file called error.log on my server that I need to frequently truncate. I have rw permissions for the file. Opening the file in vi > deleting all content > saving wo
Any one can try this command to truncate any file in linux system
This will surely work in any format :
truncate -s 0 file.txt
the credit goes for my senior colleague for this:
:> filename
This will not break log files, so you can even use it on syslog, for example.
You have the noclobber
option set. The error looks like it's from csh, so you would do:
cat /dev/null >! file
If I'm wrong and you are using bash, you should do:
cat /dev/null >| file
in bash, you can also shorten that to:
>| file