I have a text file in my home directory which receives data regularly through a cron job. Because the cron job provides dynamic data, I would also want to set a cron job to empty the file contents (the file must still exist). I don't need help with cron, just the command which can help with emptying the file.
Ubuntu – Emptying the contents of a text file
command line
Best Answer
The simplest way:
This is a less obvious way and probably less readable in a shell script by others, but it's all you need.
Because
>
is not actually a really command (it is bash builtin) you can't use:when you don't have permissions on that file. But you can use: