There are various tools to truncate large text files under UNIX / Linux operating systems.
Options #1: Shell Output Redirction
Your shell can truncate text file and make the size to zero using redirection:> {filename}Please note that largefile.txt file is created if it doesn't exist. And largefile.txt file is overwritten if it exits.
ls -l largefile.txt
> largefile.txt
ls -l largefile.txt
Option #2: truncate Command
Use the truncate command to shrink or extend the size of each FILE to the specified size:truncate -s 0 {filename.txt}The -s option is used to set SIZE to zero. See truncate command man page for more details:
ls -lh filename.txt
truncate -s 0 filename.txt
ls -lh filename.txt
man truncate
No comments:
Post a Comment