Splitting a large file into smaller pieces
IT News 2013. 11. 14. 13:37Splitting a large file into smaller pieces
If you have a large file and want to break it into smaller pieces, you can use the Unix split command. You can tell it what the prefix of each split file should be and it will then append an alphabet (or number) to the end of each name.In the example below, I split a file containing 100,000 lines. I instruct split
to use numeric suffixes (-d
), put 10,000 lines in each split file (-l 10000
) and use suffixes of length 3 (-a 3
). As a result, ten split files are created, each with 10,000 lines.
$ ls
hugefile
$ wc -l hugefile
100000 hugefile
$ split -d -l 10000 -a 3 hugefile hugefile.split.
$ ls
hugefile hugefile.split.005
hugefile.split.000 hugefile.split.006
hugefile.split.001 hugefile.split.007
hugefile.split.002 hugefile.split.008
hugefile.split.003 hugefile.split.009
hugefile.split.004
$ wc -l *split*
10000 hugefile.split.000
10000 hugefile.split.001
10000 hugefile.split.002
10000 hugefile.split.003
10000 hugefile.split.004
10000 hugefile.split.005
10000 hugefile.split.006
10000 hugefile.split.007
10000 hugefile.split.008
10000 hugefile.split.009
100000 total
In the example below, I split a file containing 100,000 lines. I instruct split
to use numeric suffixes (-d
), put 10,000 lines in each split file (-l 10000
) and use suffixes of length 3 (-a 3
). As a result, ten split files are created, each with 10,000 lines.
$ ls hugefile $ wc -l hugefile 100000 hugefile $ split -d -l 10000 -a 3 hugefile hugefile.split. $ ls hugefile hugefile.split.005 hugefile.split.000 hugefile.split.006 hugefile.split.001 hugefile.split.007 hugefile.split.002 hugefile.split.008 hugefile.split.003 hugefile.split.009 hugefile.split.004 $ wc -l *split* 10000 hugefile.split.000 10000 hugefile.split.001 10000 hugefile.split.002 10000 hugefile.split.003 10000 hugefile.split.004 10000 hugefile.split.005 10000 hugefile.split.006 10000 hugefile.split.007 10000 hugefile.split.008 10000 hugefile.split.009 100000 total
reference : http://fahdshariff.blogspot.kr/2011/10/splitting-large-file-into-smaller.html
UNIX에서는 위와 같이 간단하게 용량이 큰 파일을 분할할 수 있네요. 속도도 Application보다 훨씬 나은듯 합니다.
'IT News' 카테고리의 다른 글
Most Popular Programming Languages of 2014 (0) | 2014.02.06 |
---|---|
Boon JSON parser seems to be the fastest (0) | 2014.01.10 |
가트너가 밝히는 열 가지 IT 보안의 미신들 (0) | 2013.06.13 |
Apple Gearing Up for the Coming NFC- iPhone Revolution (0) | 2012.07.19 |
2011년 9월말에 시행되는 개인정보 보호법에 대한 자료 (1) | 2011.08.24 |