Linux split拆分檔案,linuxsplit拆分

來源:互聯網
上載者:User

Linux split拆分檔案,linuxsplit拆分
介紹

split可以將一個大檔案拆分成指定大小的多個檔案,並且拆分速度非常的快,拆分一個1G大小的檔案花費不到1S的時間,如果手工在windows上面進行操作估計得卡死。

 

 

選項

Usage: split [OPTION]... [INPUT [PREFIX]]Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; defaultsize is 1000 lines, and default PREFIX is `x'.  With no INPUT, or when INPUTis -, 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 just before each                            output file is opened      --help     display this help and exit      --version  output version information and exitSIZE may be (or may be an integer optionally followed by) one of following:KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. 可以用尾碼指定其它的單位Report split bugs to bug-coreutils@gnu.orgGNU coreutils home page: <http://www.gnu.org/software/coreutils/>General help using GNU software: <http://www.gnu.org/gethelp/>For complete documentation, run: info coreutils 'split invocation'

 

執行個體
[root@localhost test]# more testabcdefg

1.根據行拆分

每3行拆分成一個檔案,拆分後的檔案名稱以name開頭,以數字作為尾碼尾碼長度為1

split -l 3 test -d -a 1 name
[root@localhost test]# lltotal 16-rw-r--r--. 1 root root  6 Oct  9 19:12 name0-rw-r--r--. 1 root root  6 Oct  9 19:12 name1-rw-r--r--. 1 root root  2 Oct  9 19:12 name2-rw-r--r--. 1 root root 14 Oct  9 19:07 test

2.按位元組進行拆分

每三個位元組拆分成一個檔案,預設不加單位就是位元組,也可以帶單位比如KB,MB等

split -b 3 test -d -a 1 new
[root@localhost test]# ls -l new*-rw-r--r--. 1 root root 3 Oct  9 19:13 new0-rw-r--r--. 1 root root 3 Oct  9 19:13 new1-rw-r--r--. 1 root root 3 Oct  9 19:13 new2-rw-r--r--. 1 root root 3 Oct  9 19:13 new3-rw-r--r--. 1 root root 2 Oct  9 19:13 new4

 

總結

 spit命令很實用,比如匯入資料時將檔案進行拆分並發匯入會快很多。

 

 

 

 

備忘:

    作者:pursuer.chen

    部落格:http://www.cnblogs.com/chenmh

本網站所有隨筆都是原創,歡迎大家轉載;但轉載時必須註明文章來源,且在文章開頭明顯處給明連結。

《歡迎交流討論》

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.