ammassalik ammassalik - 25 days ago 5x
Linux Question

How to overwrite a file at bootup in linux?

I am redirecting bootup logs from multiple places to a text file.i use (

) append while redirecting so that existing content would not be overwritten during successive logging. How can I make sure that file is overwritten and a clean state is provided during bootup?


As you say, >> is for apending.

Use > to overwrite the file with the new content.

If you want to simply clear the log file before you start appending to it, use echo "" > mylogfile to truncate it to an empty string.