Linux Command character wear Command-split
Location:/usr/bin/split
Permission: All Users
Purpose:
Usage: split [OPTION]... [INPUT [PREFIX]
Option:
-B can be followed by the size of the file, which can be added with units, such as B, k, and m.
-L split by number of rows
PREFIX: a PREFIX that can be used as the PREFIX of a cut file.
Here, col1 is the leading character. Three files are generated: col1aa, col1ab, and col1ac.
$ Split-B 1 k col col1 $ ls-hl total usage 80K-rw-rw-r -- 1 cwjy1202 cwjy1202 54 January 8 00:11 a-rw-r -- 1 cwjy1202 cwjy1202 39 January 11 12:58 B-rw- rw-r -- 1 cwjy1202 cwjy1202 54 January 8 22:09 c-rw-r -- 1 cwjy1202 cwjy1202 3.0 K January 11 18:50 col-rw-r -- 1 cwjy1202 cwjy1202 1.0 K January 12 00:09 col1aa-rw-rw-r -- 1 cwjy1202 cwjy1202 1.0 K January 12 00:09 col1ab-rw-rw-r -- 1 cwjy1202 cwjy1202 1006 January 12 00:09 col1ac-rw-rw-r -- 1 cwjy1202 cwjy1202 3.0 K January 11 18:45 col. list-rw-r -- 1 cwjy1202 cwjy1202 75 12 27 mudidrwxr-xr-x 2 cwjy1202 cwjy1202 4.0 K 12 29 myDir-rwxr-xr-x 1 cwjy1202 cwjy1201202 15 K 12 28 17:24 nginx-rw-r -- 1 cwjy1202 cwjy1202 16 K 12 27 nginxlog-rw ------- 1 cwjy1202 cwjy1202 1004 August 29 R language flowchart. r-rw-r -- 1 cwjy1202 cwjy1202 33 Aug 17 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 coglad.
$ Split-l 20 col $ ls-hl total usage 84K-rw-rw-r -- 1 cwjy1202 cwjy1202 54 January 8 00:11 a-rw-r -- 1 cwjy1202 cwjy1202 39 January 11 12:58 B-rw -r -- 1 cwjy1202 cwjy1202 54 January 8 22:09 c-rw-r -- 1 cwjy1202 cwjy1202 3.0 K January 11 18:50 col-rw-r -- 1 cwjy1202 cwjy1202 921 January 12 00:13 colaa- rw-r -- 1 cwjy1202 cwjy1202 1021 January 12 00:13 colab-rw-r -- 1 cwjy1202 cwjy1202 807 January 12 00:13 colac-rw-r -- 1 cwjy1202 cwjy1202 305 January 12 00:13 coglad-rw-r -- 1 cwjy1202 cwjy1202 3.0 K January 11 18:45 col. list-rw-r -- 1 cwjy1202 cwjy1202 75 12 27 mudidrwxr-xr-x 2 cwjy1202 cwjy1202 4.0 K 12 29 myDir-rwxr-xr-x 1 cwjy1202 cwjy1201202 15 K 12 28 17:24 nginx-rw-r -- 1 cwjy1202 cwjy1202 16 K 12 27 nginxlog-rw ------- 1 cwjy1202 cwjy1202 1004 August 29 R language flowchart. r-rw-r -- 1 cwjy1202 cwjy1202 33 Aug 17 16:13 test. bc
Special Example: how to separate the following information into multiple files using five lines
$ Ls-al total usage 92drwxrwxr-x 3 cwjy1202 cwjy1202 4096 January 12 00:19. drwxrwxr-x 21 cwjy1202 cwjy1202 4096 12 27 .. -rw-r -- 1 cwjy1202 cwjy1202 54 Aug 17 00:11 a-rw-r -- 1 cwjy1202 cwjy1202 39 Aug 17 12:58 B-rw-r -- 1 cwjy1202 cwjy1202 54 Aug 17 22:09 c-rw-r -- 1 cwjy1202 cwjy1202 3054 January 11 18:50 col-rw-r -- 1 cwjy1202 cwjy1202 921 January 12 00:13 colaa-rw-r -- 1 cwjy1202 cwjy1202 1021 October 11 00:13 colab-rw-r -- 1 cwjy1202 cwjy1202 807 October 11 00:13 colac-rw-r -- 1 cwjy1202 cwjy1202 305 October 11 00:13 coglad-rw-r -- 1 cwjy1202 cwjy1202 3054 January 11 18:45 col. list-rw-r -- 1 cwjy1202 cwjy1202 75 12 27 mudidrwxr-xr-x 2 cwjy1202 cwjy1202 4096 12 29 myDir-rwxr-xr-x 1 cwjy1202 cwjy1201202 14698 12 28 17:24 nginx-rw-r -- 1 cwjy1202 cwjy1202 16298 12 27 nginxlog-rw ------- 1 cwjy1202 cwjy1202 1004 August 29 R language flowchart. r-rw-r -- 1 cwjy1202 cwjy1202 33 Aug 17 16:13 test. bc
-After split-l 5, which indicates that stdout or stdin is required.
In addition, lsal indicates the name prefix of the generated file. The generated names are lsalaa, lsalab, lsalac, and lsalad.
$ Ls-la | split-l 5-lsal $ ls-al total usage quota drwxrwxr-x 3 cwjy1202 cwjy1202 4096 January 12 00:21. drwxrwxr-x 21 cwjy1202 cwjy1202 4096 12 27 .. -rw-r -- 1 cwjy1202 cwjy1202 54 Aug 17 00:11 a-rw-r -- 1 cwjy1202 cwjy1202 39 Aug 17 12:58 B-rw-r -- 1 cwjy1202 cwjy1202 54 Aug 17 22:09 c-rw-r -- 1 cwjy1202 cwjy1202 3054 January 11 18:50 col-rw-r -- 1 cwjy1202 cwjy1202 921 January 12 00:13 colaa-rw-r -- 1 cwjy1202 cwjy1202 1021 October 11 00:13 colab-rw-r -- 1 cwjy1202 cwjy1202 807 October 11 00:13 colac-rw-r -- 1 cwjy1202 cwjy1202 305 October 11 00:13 coglad-rw-r -- 1 cwjy1202 cwjy1202 3054 January 11 18:45 col. list-rw-r -- 1 cwjy1202 cwjy1202 238 January 12 00:21 lsalaa-rw-r -- 1 cwjy1202 cwjy1202 294 January 12 00:21 lsalab-rw-r -- 1 cwjy1202 cwjy1202 302 january 12 00:21 lsalac-rw-r -- 1 cwjy1202 cwjy1202 201 January 12 00:21 lsalad-rw-r -- 1 cwjy1202 cwjy1202 75 12 27 mudidrwxr-xr-x 2 cwjy1202 cwjy1202 4096 twelve 29 myDir-rwxr-xr-x 1 cwjy1202 cwjy1202 14698 twelve 28 nginx-rw-r -- 1 cwjy1202 cwjy1202 16298 twelve 27 nginxlog-rw ------- 1 cwjy1202 cwjy1202 1004 august 29 17:24 R language flowchart. r-rw-r -- 1 cwjy1202 cwjy1202 33 Aug 17 16:13 test. bc
$ Wc-l lsal * 5 lsalaa 5 lsalab 5 lsalac 3 lsalad 18 total usage