split命令
split命令可以將一個(gè)大文件分割成很多個(gè)小文件,有時(shí)需要將文件分割成更小的片段,比如為提高可讀性,生成日志等。 選項(xiàng) -b:值為每一輸出檔案的大小,單位為 byte。 -C:每一輸出檔中,單行的最大 byte 數(shù)。 -d:使用數(shù)字作為后綴。 -l:值為每一輸出檔的列數(shù)大小。 實(shí)例 生成一個(gè)大小為100KB的測(cè)試文件: [root@localhost split]# dd if=/dev/zero bs=100k count=1 of=date.file 1+0 records in 1+0 records out 102400 bytes (102 kB) copied, 0.00043 seconds, 238 MB/s 使用split命令將上面創(chuàng)建的date.file文件分割成大小為10KB的小文件: [root@localhost split]# split -b 10k date.file [root@localhost split]# ls date.file xaa xab xac xad xae xaf xag xah xai xaj 文件被分割成多個(gè)帶有字母的后綴文件,如果想用數(shù)字后綴可使用-d參數(shù),同時(shí)可以使用-a length來指定后綴的長(zhǎng)度: [root@localhost split]# split -b 10k date.file -d -a 3 [root@localhost split]# ls date.file x000 x001 x002 x003 x004 x005 x006 x007 x008 x009 為分割后的文件指定文件名的前綴: [root@localhost split]# split -b 10k date.file -d -a 3 split_file [root@localhost split]# ls date.file split_file000 split_file001 split_file002 split_file003 split_file004 split_file005 split_file006 split_file007 split_file008 split_file009 使用-l選項(xiàng)根據(jù)文件的行數(shù)來分割文件,例如把文件分割成每個(gè)包含10行的小文件: split -l 10 date.file
來自:?http://man.linuxde.net/split
總結(jié)
- 上一篇: 分布式一致性协议Raft原理与实例
- 下一篇: 跨服务器Session共享的四种方法