Sun. Dec 22nd, 2024
Truncate Files from terminal in Unix and Linux

Sometimes when we need to get fresh logs data in existing logs files and log file is too large to open, then we need to delete content of existing log files.

There are several ways to truncate or empty files.

  1. : > application.log
  2. cat /dev/null > application.log
  3. truncate -s 0 application.log

Empty All logs file ending with .log

sudo truncate -s 0 /<directory path>/**/*.log

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *