Large file segmentation and merging of Linux commands

Source: Internet
Author: User

The split command of Linux is a good choice when faced with slicing a large file. It contains a number of parameters that support slicing by row and size.

The syntax for the split command is as follows:

Split [--help][--version][-a][-b][-c][-l] [file to be cut] [output filename prefix]
The corresponding parameters are described as follows:

-A,    suffix length used by--suffix-length=n (default is 2)-B,--bytes=size    byte size per output file-C,--line-bytes=size    The maximum byte size per line for each output file-D,--numeric-suffixes    uses a numeric suffix instead of the letter suffix-l,--lines=number    sets the number of rows per output file--help Display Help information--version    Display version Information
Here are a few examples:

1) Split the file splitTest.txt into multiple files, each file size is 10M. Command:

$ split-b 20m splittest.txt$ lssplitTest.txt  xaa  xab  xac
2) split the file splitTest.txt into multiple files, each file size is 10M. Specify the split file prefix bit split, command:

$ split-b 20m splitTest.txt  split$ lssplitaa  splitab  splitac  splitTest.txt
3) Split the file splitTest.txt into multiple files, 500,000 lines per file. Command:
$ wc-l splitTest.txt 1502216 splittest.txt$ split-l 500000 splitTest.txt  split$ lssplitaa  splitab  splitac< C7/>splitad  SplitTest.txt
4) Split the file splitTest.txt into multiple files, 500,000 lines per file. Specifies that the split file suffix is a number, the number of digits is 3 bits, and the command:

$ wc-l splitTest.txt 1502216 splittest.txt$ split-l 500000-d-a 3 splitTest.txt  split$ lssplit000  split001
   split002  split003  splitTest.txt
You can use the Cat command to merge the sliced files into a new file:

$ cat split0* > Original.txt

Reprint Please specify the Source:http://blog.csdn.net/iAm333


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.