Linux cutting command split, which can cut log files and text files

Source: Internet
Author: User

1. Split description

 

Split can be used to cut a log file to facilitate log processing. For example, if there is a 12 GB log, you need to delete a row of data and know the row number. However, using SED and VI is slow,

You can first split and then delete the line, and then re-combine it.

 

Ii. Instructions for use

 

[Root @ bogon desktop] # split -- Help

 

Usage: Split [Option] [input [prefix]

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.

 

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

-A, -- suffix-length = N use suffixes of length N (default 2)

-B, -- bytes = size put size bytes per output file

-C, -- line-bytes = size put at most size bytes of lines per output file

-D, -- Numeric-suffixes use numeric suffixes instead of alphabetic

-L, -- lines = Number put number lines per output file

-- Verbose print a diagnostic to standard error just

Before each output file is opened

-- Help display this help and exit

-- Version output version information and exit

 

Size may have a multiplier Suffix: B for 512, K for 1 K, M for 1 Meg.

 

-The last few digits of a cut file name, expressed in digits. The default value is the size of the Two-B cut files-C the number of bytes per line of the cut files-the last few digits of the cut file name Replace the letters. By default, the file is saved with the letter XX-L. Each file contains fewer lines. Iii. Examples   1. Production File Viewing  [Root @ bogon desktop] # lltotal 388-rw-r -- r -- 1 Root 4803 Feb 26 2009 gnome-terminal.desktop-rw-r -- r -- 1 Root 349027 May 5 mysql_data.gz-rw ------- 1 Root 1108 Apr 25 new filedrwxrwxrwx 2 root Root 4096 Apr 24 nfs-RW-r -- 1 Root 285 May 5 split. log 2. After cutting, the file name suffix is 3 letters  [Root @ bogon desktop] # split-A 3 split. log [root @ bogon desktop] # lltotal 396-rw-r -- r -- 1 Root 4803 Feb 26 2009 gnome-terminal.desktop-rw-r -- r -- 1 Root 349027 May 5 mysql_data.gz-rw ------- 1 Root 1108 Apr 25 new filedrwxrwxrwx 2 root Root 4096 Apr 24 nfs-RW-r -- 1 Root 285 May 5 split. log-RW-r -- 1 Root 285 May 5 xaaa 3. After the cut, the file name suffix is 3 letters. The cut file contains two lines of content for each file,  [Root @ bogon desktop] # split-A 3-L 2 split. log [root @ bogon desktop] # lltotal 412-rw-r -- r -- 1 Root 4803 Feb 26 2009 gnome-terminal.desktop-rw-r -- r -- 1 Root 349027 May 5 mysql_data.gz-rw ------- 1 Root 1108 Apr 25 new filedrwxrwxrwx 2 root Root 4096 Apr 24 nfs-RW-r -- 1 Root 285 May 5 split. log-RW-r -- 1 root 76 May 5 23:17 xaaa-RW-r -- 1 Root 109 May 5 23:17 xaab-RW-r -- r root 100 May 5 xaac 4. After the cut, the file name suffix is 3 (BIT) numbers, the cut file, each file two lines of content,  [Root @ bogon desktop] # split-A 3-L 2-D split. log [root @ bogon desktop] # lltotal 436-rw-r -- r -- 1 Root 4803 Feb 26 2009 gnome-terminal.desktop-rw-r -- r -- 1 Root 349027 May 5 mysql_data.gz-rw ------- 1 Root 1108 Apr 25 new filedrwxrwxrwx 2 root Root 4096 Apr 24 nfs-RW-r -- 1 Root 285 May 5 split. log-RW-r -- 1 root 76 May 5 x000-rw-r -- r -- 1 Root 109 May 5 x001-rw-r -- r -- 1 Root 100 May 5 x002-rw-r -- r -- 1 root 76 May 5 xaaa-RW-r -- 1 Root 109 May 5 xaab-RW-r -- 1 Root 100 May 5 xaac Iv. ReferenceMan split

Disclaimer: This document can be changed at will, but must be signed by the original author

Author: Phoenix dancer QQ: 578989855

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.