Posted in Linux
I am sure you know that situation when you need to delete file contents in Linux. Just think about it - you have some log files on your Linux workstation or server and their size just keeps growing and growing... Sometimes it's really necessary to delete the content of the file but keep the file itself. So... how can you do that?
In Linux deleting file content while keeping the file is quite easy! Just use the following command from command line:
cat /dev/null > YOURFILENAME
I recommend you to backup the file first because you never know when something bad can happen... ;) Personally I use this command quite often on my servers and it works like a charm every time.