Linux切割命令split ,可以切割記錄檔,文字檔

來源:互聯網
上載者:User

一.split說明

 

split可以用來切割一個記錄檔,這樣便於處理日誌。比如有一個12G的日誌,需要刪除某一行資料,知道行號,但用sed和vi比較慢,

就可以先用  split 切割 ,然後再刪除那行,最後再重組合

 

二.使用說明

 

[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 1K, m for 1 Meg.

 

-a  切割後的檔案名稱的後幾位,用幾位元字表示。預設是兩位-b  切割後的檔案的大小-C  切割後的檔案每行多少位元組數-d  切割後的檔案名稱的後幾位用數字代替字母。預設是字母xx-l   切割後的檔案,每個檔案都少行  三.舉例說明   1.產看檔案  [root@bogon Desktop]# lltotal 388-rw-r--r-- 1 root root   4803 Feb 26  2009 gnome-terminal.desktop-rw-r--r-- 1 root root 349027 May  5 04:06 mysql_data.gz-rw------- 1 root root   1108 Apr 25 19:23 new filedrwxrwxrwx 2 root root   4096 Apr 24 06:39 NFS-rw-r--r-- 1 root root    285 May  5 22:02 split.log  2.切割後檔案名稱尾碼為3個字母  [root@bogon Desktop]# split -a 3  split.log     [root@bogon Desktop]# lltotal 396-rw-r--r-- 1 root root   4803 Feb 26  2009 gnome-terminal.desktop-rw-r--r-- 1 root root 349027 May  5 04:06 mysql_data.gz-rw------- 1 root root   1108 Apr 25 19:23 new filedrwxrwxrwx 2 root root   4096 Apr 24 06:39 NFS-rw-r--r-- 1 root root    285 May  5 22:02 split.log-rw-r--r-- 1 root root    285 May  5 23:16 xaaa  3.切割後檔案名稱尾碼為3個字母,切割後的檔案,每個檔案兩行內容,  [root@bogon Desktop]# split -a 3 -l 2 split.log[root@bogon Desktop]# lltotal 412-rw-r--r-- 1 root root   4803 Feb 26  2009 gnome-terminal.desktop-rw-r--r-- 1 root root 349027 May  5 04:06 mysql_data.gz-rw------- 1 root root   1108 Apr 25 19:23 new filedrwxrwxrwx 2 root root   4096 Apr 24 06:39 NFS-rw-r--r-- 1 root root    285 May  5 22:02 split.log-rw-r--r-- 1 root root     76 May  5 23:17 xaaa-rw-r--r-- 1 root root    109 May  5 23:17 xaab-rw-r--r-- 1 root root    100 May  5 23:17 xaac  4.切割後檔案名稱尾碼為3個(位)數字,切割後的檔案,每個檔案兩行內容,  [root@bogon Desktop]# split -a 3 -l 2 -d  split.log[root@bogon Desktop]# lltotal 436-rw-r--r-- 1 root root   4803 Feb 26  2009 gnome-terminal.desktop-rw-r--r-- 1 root root 349027 May  5 04:06 mysql_data.gz-rw------- 1 root root   1108 Apr 25 19:23 new filedrwxrwxrwx 2 root root   4096 Apr 24 06:39 NFS-rw-r--r-- 1 root root    285 May  5 22:02 split.log-rw-r--r-- 1 root root     76 May  5 23:17 x000-rw-r--r-- 1 root 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     76 May  5 23:17 xaaa-rw-r--r-- 1 root root    109 May  5 23:17 xaab-rw-r--r-- 1 root root    100 May  5 23:17 xaac   四.參考man split

聲明:本文檔可以隨意更改,但必須署名原作者

作者:鳳凰舞者 qq:578989855

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.