Linux Common Commands--split

Source: Internet
Author: User

1. Function: Split large files into multiple small files

2. Usage: Split [parameter] file [name]

3. Parameters:

-B: Divide the document by byte size;

-D: Use a number as a suffix.

-L: The value is the size of the number of columns per output file.

4. Example

[Email protected] ~]$ Head-10/etc/passwd>/home/mysql/passwd.txt

Example 1: Dividing the/home/mysql/passwd.txt by 4 rows per file

[Email protected] ~]$ split-4 passwd.txt

[[email protected] ~]$ for file in ' ls|grep-v "Passwd.txt" ';d o echo ' wc-l $file ';

4 XAA

4 Xab

2 Xac

These three are automatically named files, and the source files are still present after the file is split. The source files are 10 lines in total, divided by 4 rows per file, and the number of rows for three files is 4,4,2.

Example 2: Splitting a file by byte

[Email protected] ~]$ Split-b passwd.txt

[Email protected] ~]$ more XAA

Root:x:0:0:root:/root:/bin/bash

Bin:x:1:1:bin:/bin:/sbin/nologin

Daemon:x:2:2:daemon:/sbin:/sbin/nologin

Adm:x:3:4:adm:/var/adm:/sbin/nologin

Lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

sync:x:5:0:sync:/

[Email protected] ~]$ more Xab

Sbin:/bin/sync

Shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

Halt:x:7:0:halt:/sbin:/sbin/halt

Mail:x:8:12:mail:/var/spool/mail:/sbin/nologin

Uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin

File discontinuity occurs by byte splitting

Example 3: Specifying the file name and starting number

[Email protected] ~]$ split-l 4 passwd.txt "passwd"-D

[[email protected] ~]$ ls |grep-v "Passwd.txt"

Passwd00

Passwd01

Passwd02

The file name is changed to a format that begins with passwd and ends with a number.


Linux Common Commands--split

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.