How to truncate or empty files from terminal Unix or Linux OS
Posted on 18 Dec 2024 05:04 PM by
Admin Admin
Unix
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.
- : > application.log
- cat /dev/null > application.log
- truncate -s 0 application.log
Empty All logs file ending with .log
sudo truncate -s 0 /<directory path>/**/*.log