How to use Linux large file split split and merge Cat

Source: Internet
Author: User

This article mainly introduces two Linux commands: Split and Cat. Among them, I believe that everyone is familiar with the cat command, generally used to view the contents of a file, but it also other functions, such as the introduction of the file merge function, it can combine multiple file contents into a file. From the split word meaning does not take understanding, it is the meaning of division, often used to split large files. This is detailed below.

Split command-split file

Syntax: Split [–help][–version][-][-l][-b][-c][-d][-a][file to be cut] [output FILENAME]

–version displaying version information

– OR-L, specify how many lines are cut once for text file segmentation

-b Specifies the size of the cut file, in units m or K

-C is similar to-B but maintains the integrity of each row as much as possible

-d use numbers instead of letters as suffix names

-a specifies the length of the suffix name, which defaults to 2 bits

Example 1

Cut the a.tar.gz package by each 5M size:

Split-b 5m a.tar.gz a.tar.gz.

The file name that is output later: "A.tar.gz.", the words that are not specified are output in xaa,xab,xac form. If the file name is not appended. , the output file name is linked to the suffix and is not intuitive.

Example 2

Use the ' | ' Pipeline to merge packaged split actions:

tar-zcf-a | Split-b 5m-a.tar.gz.

Note: Before and after the pipe two without parameters "-" is not omitted, he as the tar ouput and split input parameters.

Cat command

Syntax: Cat [-ABEENSTTUV] [help] [–version] FileName

-N or –number the number of rows for all outputs starting from 1

-B or –number-nonblank and-n similar, except for blank lines not numbered

-S or –squeeze-blank when you encounter a blank line that has more than two consecutive lines, replace the blank line with one line

-V or –show-nonprinting

#cat常用功能
#一次显示整个文件
Cat filename

#创建一个文件, only new files can be created and existing files cannot be edited
Cat > FileName

#将几个文件合并为一个文件.
Cat File1 file2 > File

So the above example merges the split file, which you can use:

#合并
Cat a.tar.gz.* > A.tar.gz
#合并并解压
Cat a.tar.gz.* | Tar-zxv

The above excerpt from: http://www.ezencart.com/pages/1001.html

How to use Linux large file split split and merge Cat

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.