Detailed explanation of split command

Linux -- split file split operation

 

SPLIT(1)                User Commands                SPLIT(1)

 

NAME

    split - split a file into pieces

 

SYNOPSIS Summary (Syntax)

    split [OPTION]... [INPUT [PREFIX]]

 

DESCRIPTION

    Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.  With no INPUT,  or  when INPUT is -, read standard input.

    Output the input content into a fixed-size output file, such as: PREFIXaa, PREFIXab, ...; the default size is 1000 lines, the default prefix is ​​"x", when no input is specified or the input is "-", from the standard input read.

 

    Mandatory arguments to long options are mandatory for short options too.

    Arguments that are required for long options are also required for short options.

 

    -a, --suffix-length=N

        generate suffixes of length N (default 2)

        Make the generated suffix length N, default is 2.

 

    --additional-suffix=SUFFIX

        append an additional SUFFIX to file names

        Append an extra string to the filename suffix.

 

    -b, --bytes=SIZE

        put SIZE bytes per output file

        Write SIZE size to each output file, only the last file size <= SIZE.

 

[root@user test]# ll
total 672
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
[root@user test]# split -b 100K catalina.out
[root@user test]# ll
total 1368
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xaa
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xab
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xac
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xad
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xae
-rw-r - r-- 1 root root 102400 Feb 27 16:37 xaf
-rw-r--r-- 1 root root  67310 Feb 27 16:37 xag
[root@user test]#

 

    -C, --line-bytes=SIZE

        put at most SIZE bytes of lines per output file

        At most SIZE bytes are written to each output file, in records, and each file produced is <= SIZE.

 

[root@user test]#
[root@user test]# ll
total 672
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
[root@user test]# split -C 100K catalina.out
[root@user test]# ll
total 1368
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
-rw-r--r-- 1 root root 102392 Feb 27 16:36 xaa
-rw-r--r-- 1 root root 102357 Feb 27 16:36 xab
-rw-r--r-- 1 root root 102203 Feb 27 16:36 xac
-rw-r--r-- 1 root root 102346 Feb 27 16:36 xad
-rw-r--r-- 1 root root 102384 Feb 27 16:36 xae
-rw-r - r-- 1 root root 102387 Feb 27 16:36 xaf
-rw-r--r-- 1 root root  67641 Feb 27 16:36 xag
[root@user test]#

 

    -d, --numeric-suffixes[=FROM]

        use numeric suffixes instead of alphabetic; FROM changes the start value (default 0)

        Use numbers instead of letter suffixes, and FROM specifies the starting position of the number, which starts at 0 by default.

 

 

[root@user test]# ll
total 672
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
[root@user test]# split -l 50000 catalina.out
[root@user test]# ll
total 1344
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
-rw-r--r-- 1 root root 681710 Feb 27 16:38 xaa
[root@user test]# rm -rf xaa
[root@user test]# split -l 50000 -d catalina.out
[root@user test]# ll
total 1344
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
-rw-r--r-- 1 root root 681710 Feb 27 16:38 x00
[root@user test]#

 

    -e, --elide-empty-files

        do not generate empty output files with '-n'

        Used in conjunction with -n, do not generate an empty output file.

 

    --filter=COMMAND

        write to shell COMMAND; file name is $FILE

        Takes the result as input to COMMAND, similar to the pipe character.

 

    -l, --lines=NUMBER

        put NUMBER lines per output file

        Write Number lines to each output file, the last file <= NUMBER lines.

 

    -n, --number=CHUNKS

        generate CHUNKS output files; see explanation below

        Enables the CHUNKS output file to be generated, see below for instructions.

 

    -u, --unbuffered

        immediately copy input to output with '-n r/...'

        Write input to output file immediately, use with -nr/....

 

    --verbose

        print a diagnostic just before each output file is opened

        Print diagnostic information before opening or creating each output file.

 

    --help display this help and exit

        Display help for this command and exit

 

    --version

        output version information and exit

        Enter version information and exit

 

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

    The SIZE parameter is an integer and an optional parameter (example: 10M = 10*1024*1024). Singular includes K, M, G, T, P, E, Z, Y (1024 in base) or KB, MB, ... (base 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 l/K/N   output Kth of N to  stdout  without  splitting  lines  r/N like 'l' but use round robin distribution r/K/N   likewise but only output Kth of N to stdout

    N    split into N files based on size of input

    Divide input into N parts based on size

    K/N  output Kth of N to stdout

    Divide the input into N parts based on size, and print the Kth part

    l/N  split into N files without splitting lines

    Divide the input into N parts based on the size, but do not truncate the line, and fill in the broken line forward

    l/K/N   output Kth of N to stdout without splitting lines

    Divide the input into N parts based on size, and print the Kth part without truncating the line.

    r/N     like 'l' but use round robin distribution

    Same as l, using circular assignment

    r/K/N   likewise but only output Kth of N to stdout

    Same as l, use cyclic allocation, divide it into N parts, print the Kth part, but do not truncate the line, and fill up the line if there is a broken line

 

    GNU coreutils online help: <http://www.gnu.org/software/coreutils/>

    Report split translation bugs to <http://translationproject.org/team/>

 

AUTHOR

    Written by Torbjorn Granlund and Richard M. Stallman.

 

COPYRIGHT

    Copyright (C) 2013 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are  free  to  change  and  redistribute  it. There is NO WARRANTY, to the extent permitted by law.

 

SEE ALSO

    The  full documentation for split is maintained as a Texinfo manual.  If the info and split programs are properly installed  at  your  site,  the command info coreutils 'split invocation' should give you access to the complete manual.

    The complete documentation for split is maintained as a Texinfo manual. If both the info and split programs are installed, execute the command:

        info coreutils 'split invocation'

    should give you access to the entire manual.

 

GNU coreutils 8.22           June 2014                  SPLIT(1)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326345112&siteId=291194637