0

I am reading the split --help but I am unsure how to execute this command with the round robin feature, can someone please give me an example

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

-n, --number=CHUNKS     generate CHUNKS output files; see explanation below

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).

CHUNKS may be:
    N       split into N files based on size of input
    K/N     output Kth of N to stdout
    l/N     split into N files without splitting lines/records
    l/K/N   output Kth of N to stdout without splitting lines/records          
--> r/N     like 'l' but use round robin distribution
    r/K/N   likewise but only output Kth of N to stdout

1 Answer 1

1

Example executed in Bash:

# create a testfile with 10 lines
$ printf 'line %s\n' {1..10} > testin

# split into 3 files with round robin distribution and numeric suffix (`-d`)
$ split -d -nr/3 testin testout

# show line count
$ wc -l testout*
 4 testout00
 3 testout01
 3 testout02
10 total

# show content
$ head testout*
==> testout00 <==
line 1
line 4
line 7
line 10

==> testout01 <==
line 2
line 5
line 8

==> testout02 <==
line 3
line 6
line 9

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .