Get the App
SLTechnology News&Howtos  ›  Servers  › 

Commands for splitting and merging CentOS files

Shulou Source: shulou.com Published: 2022-06-01 12:16:06 10月03日 Update

This article mainly explains the "CentOS file division and merge commands", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "CentOS file division and merge commands" bar!

The syntax of the split command is:

Split [--help] [--version] [- a] [- b] [- C] [- l] [file to be cut] [output file name 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 maximum byte size per line of each output file-d,-- numeric-suffixes uses numeric suffix instead of letter suffix-l,-- lines=NUMBER sets the number of lines per output file-- help displays help-- version displays version information.

Here are a few examples:

1) the file splitTest.txt is divided into multiple files, and the size of each file is 10m. Command:

$split-b 20m splitTest.txt $ls splitTest.txt xaa xab xac

2) the file splitTest.txt is divided into multiple files, and the size of each file is 10m. Specify the split file prefix bit split, command:

$split-b 20m splitTest.txt split $ls splitaa splitab splitac splitTest.txt

3) split the file splitTest.txt into multiple files, each with 500000 lines. Command:

$wc-l splitTest.txt 1502216 splitTest.txt $split-l 500000 splitTest.txt split $ls splitaa splitab splitac splitad splitTest.txt

4) split the file splitTest.txt into multiple files, each with 500000 lines. Specify that the suffix of the split file is a number and the number of digits is 3 digits, and the command:

$wc-l splitTest.txt 1502216 splitTest.txt $split-l 500000-d-a 3 splitTest.txt split $ls split000 split001 split002 split003 splitTest.txt

You can use the cat command to merge the split file into a new file:

$cat split0* > original.txt

Thank you for your reading, the above is the content of the "CentOS file division and merge command", after the study of this article, I believe you have a deeper understanding of the CentOS file division and merge command this problem, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Files commands suffixes multiple size output numbers learning information content prefixes bytes maximum digits examples parameters letters that is ideas situations Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Redmi MariaDB Shulou Tech Info