Get the App
SLTechnology News&Howtos  ›  Servers  › 

Introduction to the use of split Command in Linux system

Shulou Source: shulou.com Published: 2022-06-01 15:50:05 09月28日 Update

This article mainly explains "introduction to the use of split commands in Linux system". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the introduction to the use of split commands in the Linux system.

Location: / usr/bin/split

Permissions: all users

Function:

Usage: split [OPTION]. [INPUT [PREFIX]]

Options:

-b can be followed by the size of the file that can be cut, and units can be added, for example: bMagol k, m

-l split by the number of rows

PREFIX: leader, which can be used as the leading text of a cut file

Here col1 is the leader, generating three files col1aa, col1ab, and col1ac

The code is as follows:

$split-b 1k col col1

$ls-hl

Total dosage 80K

-rw-rw-r-- 1 cwjy1202 cwjy1202 54 January 8 00:11 a

-rw-rw-r-- 1 cwjy1202 cwjy1202 39 January 11 12:58 b

-rw-rw-r-- 1 cwjy1202 cwjy1202 54 January 8 22:09 c

-rw-rw-r-- 1 cwjy1202 cwjy1202 3.0K January 11 18:50 col

-rw-rw-r-- 1 cwjy1202 cwjy1202 1.0K January 12 00:09 col1aa

-rw-rw-r-- 1 cwjy1202 cwjy1202 1.0K January 12 00:09 col1ab

-rw-rw-r-- 1 cwjy1202 cwjy1202 1006 January 12 00:09 col1ac

-rw-rw-r-- 1 cwjy1202 cwjy1202 3.0K January 11 18:45 col.list

-rw-rw-r-- 1 cwjy1202 cwjy1202 75 12 27 22:09 mudi

Drwxr-xr-x 2 cwjy1202 cwjy1202 4.0K 12 29 23:47 myDir

-rwxr-xr-x 1 cwjy1202 cwjy1202 15K 12 28 23:20 nginx

-rw-rw-r-- 1 cwjy1202 cwjy1202 16K 12 27 20:16 nginxlog

-rw- 1 cwjy1202 cwjy1202 1004 August 29 17:24 R language flow chart. R

-rw-rw-r-- 1 cwjy1202 cwjy1202 33 January 3 16:13 test.bc

The file col is separated by the number of lines, and the leading character of the generated file is col, which is divided into three files: colaa, colab, colac and colad.

The code is as follows:

$split-l 20 col col

$ls-hl

Total dosage 84K

-rw-rw-r-- 1 cwjy1202 cwjy1202 54 January 8 00:11 a

-rw-rw-r-- 1 cwjy1202 cwjy1202 39 January 11 12:58 b

-rw-rw-r-- 1 cwjy1202 cwjy1202 54 January 8 22:09 c

-rw-rw-r-- 1 cwjy1202 cwjy1202 3.0K January 11 18:50 col

-rw-rw-r-- 1 cwjy1202 cwjy1202 921 January 12 00:13 colaa

-rw-rw-r-- 1 cwjy1202 cwjy1202 1021 January 12 00:13 colab

-rw-rw-r-- 1 cwjy1202 cwjy1202 807 January 12 00:13 colac

-rw-rw-r-- 1 cwjy1202 cwjy1202 305 January 12 00:13 colad

-rw-rw-r-- 1 cwjy1202 cwjy1202 3.0K January 11 18:45 col.list

-rw-rw-r-- 1 cwjy1202 cwjy1202 75 12 27 22:09 mudi

Drwxr-xr-x 2 cwjy1202 cwjy1202 4.0K 12 29 23:47 myDir

-rwxr-xr-x 1 cwjy1202 cwjy1202 15K 12 28 23:20 nginx

-rw-rw-r-- 1 cwjy1202 cwjy1202 16K 12 27 20:16 nginxlog

-rw- 1 cwjy1202 cwjy1202 1004 August 29 17:24 R language flow chart. R

-rw-rw-r-- 1 cwjy1202 cwjy1202 33 January 3 16:13 test.bc

Special example: how to separate the following information into multiple files with 5 lines

The code is as follows:

$ls-al

Total dosage 92

Drwxrwxr-x 3 cwjy1202 cwjy1202 4096 January 12 00:19.

Drwxrwxr-x 21 cwjy1202 cwjy1202 4096 12 27 21:23..

-rw-rw-r-- 1 cwjy1202 cwjy1202 54 January 8 00:11 a

-rw-rw-r-- 1 cwjy1202 cwjy1202 39 January 11 12:58 b

-rw-rw-r-- 1 cwjy1202 cwjy1202 54 January 8 22:09 c

-rw-rw-r-- 1 cwjy1202 cwjy1202 3054 January 11 18:50 col

-rw-rw-r-- 1 cwjy1202 cwjy1202 921 January 12 00:13 colaa

-rw-rw-r-- 1 cwjy1202 cwjy1202 1021 January 12 00:13 colab

-rw-rw-r-- 1 cwjy1202 cwjy1202 807 January 12 00:13 colac

-rw-rw-r-- 1 cwjy1202 cwjy1202 305 January 12 00:13 colad

-rw-rw-r-- 1 cwjy1202 cwjy1202 3054 January 11 18:45 col.list

-rw-rw-r-- 1 cwjy1202 cwjy1202 75 12 27 22:09 mudi

Drwxr-xr-x 2 cwjy1202 cwjy1202 4096 12 29 23:47 myDir

-rwxr-xr-x 1 cwjy1202 cwjy1202 14698 12 28 23:20 nginx

-rw-rw-r-- 1 cwjy1202 cwjy1202 16298 12 27 20:16 nginxlog

-rw- 1 cwjy1202 cwjy1202 1004 August 29 17:24 R language flow chart. R

-rw-rw-r-- 1 cwjy1202 cwjy1202 33 January 3 16:13 test.bc

As follows: the-after split-l 5, that-indicates the need for stdout or stdin

In addition, lsal represents the name leader of the generated file, and the generated name is: lsalaa, lsalab, lsalac, lsalad

The code is as follows:

$ls-la | split-l 5-lsal

$ls-al

Total dosage 108

Drwxrwxr-x 3 cwjy1202 cwjy1202 4096 January 12 00:21.

Drwxrwxr-x 21 cwjy1202 cwjy1202 4096 12 27 21:23..

-rw-rw-r-- 1 cwjy1202 cwjy1202 54 January 8 00:11 a

-rw-rw-r-- 1 cwjy1202 cwjy1202 39 January 11 12:58 b

-rw-rw-r-- 1 cwjy1202 cwjy1202 54 January 8 22:09 c

-rw-rw-r-- 1 cwjy1202 cwjy1202 3054 January 11 18:50 col

-rw-rw-r-- 1 cwjy1202 cwjy1202 921 January 12 00:13 colaa

-rw-rw-r-- 1 cwjy1202 cwjy1202 1021 January 12 00:13 colab

-rw-rw-r-- 1 cwjy1202 cwjy1202 807 January 12 00:13 colac

-rw-rw-r-- 1 cwjy1202 cwjy1202 305 January 12 00:13 colad

-rw-rw-r-- 1 cwjy1202 cwjy1202 3054 January 11 18:45 col.list

-rw-rw-r-- 1 cwjy1202 cwjy1202 238 January 12 00:21 lsalaa

-rw-rw-r-- 1 cwjy1202 cwjy1202 294 January 12 00:21 lsalab

-rw-rw-r-- 1 cwjy1202 cwjy1202 302 January 12 00:21 lsalac

-rw-rw-r-- 1 cwjy1202 cwjy1202 201 January 12 00:21 lsalad

-rw-rw-r-- 1 cwjy1202 cwjy1202 75 12 27 22:09 mudi

Drwxr-xr-x 2 cwjy1202 cwjy1202 4096 12 29 23:47 myDir

-rwxr-xr-x 1 cwjy1202 cwjy1202 14698 12 28 23:20 nginx

-rw-rw-r-- 1 cwjy1202 cwjy1202 16298 12 27 20:16 nginxlog

-rw- 1 cwjy1202 cwjy1202 1004 August 29 17:24 R language flow chart. R

-rw-rw-r-- 1 cwjy1202 cwjy1202 33 January 3 16:13 test.bc

The code is as follows:

$wc-l lsal*

5 lsalaa

5 lsalab

5 lsalac

3 lsalad

18 Total dosage

At this point, I believe you have a deeper understanding of the "introduction to the use of split commands in the Linux system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: File code lead usage process flowchart language generation command system content name learning practical deeper special three location function example Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn Docker Linux Xiaomi