http://www.cyberciti.biz/faq/truncate-large-text-file-in-unix-linux/
large text files under UNIX / Linux operating systems as follows.Options #1: Shell Output Redirction
Your can truncate text file and make the size to zero usingredirection:
> {filename}
ls -l largefile.txt
> largefile.txt
ls -l largefile.txt
Please note that largefile.txt file is created if it doesn't exist. And largefile.txt file is overwritten if it exists.
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}
ls -lh filename.txt
truncate -s 0 filename.txt
ls -lh filename.txt
The -s option is used to set SIZE to zero. See truncate command man page for more details:
man truncate
Option #3: logrotate Utility
logrotate command is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large. See how to use logrotate command to rotates, compresses, and mails system logs stored in /var/log and other locations under UNIX / Linux oses.
Option #4: /dev/null
The null device /dev/null act as the black hole that discards all data written to it under Unix like operating system. You can use it as follows (hat tip to Philippe Petrinko):
cp /dev/null largefile.txt
OR
cat /dev/null > largefile.txt