Linux Cut command split, can cut log files, text file __linux

Source: Internet
Author: User
Tags numeric

A. Split description

Split can be used to cut a log file, making it easier to process logs. For example, there is a 12G log, you need to delete a row of data, know the line number, but with the SED and vi relatively slow,

You can cut the split first, then delete the line, and then regroup.

Two. Instructions for use

 

[Root@bogon desktop]# Split--help

Usage:split [OPTION] [INPUT [PREFIX]]

Output fixed-size pieces of INPUT to Prefixaa, Prefixab, ...; Default

The 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 on 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, K to 1K, M for 1 Meg.

The latter of the file name after the cut, expressed in several digits. The default is the size of the two-bit-B-cut file----the number of bytes per line after the cut--------after the file name after the cut after the number of digits instead of letters. The default is the letter xx-l after cutting the file, each file less linethree. Examples   1. Production of documents  [Root@bogon desktop]# ll total 388-rw-r--r--1 root 4803 Feb-2009 gnome-terminal.desktop-rw-r--r--1 root Roo T 349027 May 5 04:06 mysql_data.gz-rw-------1 root root 1108 Apr 19:23 new file drwxrwxrwx 2 root 4096 Apr 06:39 nfs-rw-r--r--1 Root 285 May 5 22:02 Split.log2. After cutting the filename suffix to 3 letters  [Root@bogon desktop]# split-a 3 Split.log [Root@bogon desktop]# ll total 396-rw-r--r--1 root root 4803 Feb 26 2009 gnome-terminal.desktop-rw-r--r--1 root 349027 May 5 04:06 mysql_data.gz-rw-------1 root 1108 Apr 25 19:23 New file drwxrwxrwx 2 root 4096 Apr 06:39 nfs-rw-r--r--1 root root 285 May 5 22:02 split.log-rw-r-- r--1 Root 285 May 5 23:16 XAAA3. After cutting the filename suffix to 3 letters, after cutting the file, each file two lines of content,  [Root@bogon desktop]# split-a 3-l 2 Split.log [Root@bogon desktop]# ll total 412-rw-r--r--1 root 4803 Feb 26 2 009 gnome-terminal.desktop-rw-r--r--1 Root 349027 May 5 04:06 mysql_data.gz-rw-------1 root 1108 Apr 25 1 9:23 New file drwxrwxrwx 2 root 4096 Apr 06:39 nfs-rw-r--r--1 root root 285 May 5 22:02 split.log-rw-r--r  --1 root 5 23:17 xaaa-rw-r--r--1 root 109 May 5 23:17 xaab-rw-r--r--1 root 5 23:17 XAAC4. After cutting the filename suffix to 3 (bit) number, after cutting the file, each file two lines of content,  [Root@bogon desktop]# split-a 3-l 2-d split.log [root@bogon desktop]# ll total 436-rw-r--r--1 root 4803 Feb 2 6 2009 gnome-terminal.desktop-rw-r--r--1 root root 349027 May 5 04:06 mysql_data.gz-rw-------1 root root 1108 Apr 19:23 New file drwxrwxrwx 2 root 4096 Apr 06:39 nfs-rw-r--r--1 root root 285 May 5 22:02 split.log-rw- r--r--1 root 5 23:17 x000-rw-r--r--1 root 109 May 5 23:17 x001-rw-r--r--1 root root 100 May 5 23:17 x002-rw-r--r--1 root root for May 5 23:17 xaaa-rw-r--r--1 root root 109 May 5 23:17 Xaab-rw-r--r --1 root May 5 23:17 XAACfour. For referenceMans 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.