게시물 1,376건
   
대용량 파일 축소/삭제 (Truncate Large Text File in UNIX / Linux)
글쓴이 : 최고관리자 날짜 : 2013-04-24 (수) 14:37 조회 : 7818
글주소 :
                                
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
 

이름 패스워드
비밀글 (체크하면 글쓴이만 내용을 확인할 수 있습니다.)
왼쪽의 글자를 입력하세요.
   

 



 
사이트명 : 모지리네 | 대표 : 이경현 | 개인커뮤니티 : 랭키닷컴 운영체제(OS) | 경기도 성남시 분당구 | 전자우편 : mojily골뱅이chonnom.com Copyright ⓒ www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.