zoukankan      html  css  js  c++  java
  • Linux命令之split

    split用来将大文件分割成小文件。有时文件越来越大,传送这些文件时,首先将其分割可能更容易。

    使用vi或其他工具诸如sort时,如果文件对于工作缓冲区太大,也会存在一些问题。

    因此有时没有选择余地,必须将文件分割成小的碎片。

    split命令一般格式:

    split -output_file-size input-filename output-filename

    这里output_file-size指的是文本文件被分割的行数。split查看文件时,output_file-size选项指定将文件按每个最多5行分割。

    如果有个文件有12行,那么将分割成3个文件,分别有5、5、2行。

    每个文件格式为x [ a a ]到x [ z z ],x为文件名首字母, [ a a]、[ z z ]为文件名剩余部分顺序字符组合

    下面的例子解释这一点。

    [root@linux-node1 test]# split -5 file2
    [root@linux-node1 test]# ll
    total 16
    -rw-r--r-- 1 root root 156 Apr 2 10:36 file2
    -rw-r--r-- 1 root root  65Apr  2 10:39 xaa
    -rw-r--r-- 1 root root  65Apr  2 10:39 xab
    -rw-r--r-- 1 root root  26Apr  2 10:39 xac
    [root@linux-node1 test]# cat xaa
    1001  hisk01
    1002  hisk02
    1003  hisk03
    1004  hisk04
    1005  hisk05
    [root@linux-node1 test]# cat xab
    1006  hisk06
    1007  hisk07
    1008  hisk08
    1009  hisk09
    10010 hisk10
    [root@linux-node1 test]# cat xac
    10011 hisk11
    10012 hisk12
    [root@linux-node1 test]# cat file2
    1001  hisk01
    1002  hisk02
    1003  hisk03
    1004  hisk04
    1005  hisk05
    1006  hisk06
    1007  hisk07
    1008  hisk08
    1009  hisk09
    10010 hisk10
    10011 hisk11
    10012 hisk12
    [root@linux-node1 test]# split -3 file2
    [root@linux-node1 test]# ll
    total 20
    -rw-r--r-- 1 root root 156 Apr 2 10:36 file2
    -rw-r--r-- 1 root root  39Apr  2 10:37 xaa
    -rw-r--r-- 1 root root  39Apr  2 10:37 xab
    -rw-r--r-- 1 root root  39Apr  2 10:37 xac
    -rw-r--r-- 1 root root  39Apr  2 10:37 xad
    [root@linux-node1 test]# cat xaa
    1001  hisk01
    1002  hisk02
    1003  hisk03
    [root@linux-node1 test]# cat xab
    1004  hisk04
    1005  hisk05
    1006  hisk06
    [root@linux-node1 test]# cat xac
    1007  hisk07
    1008  hisk08
    1009  hisk09
    [root@linux-node1 test]# cat xad
    10010 hisk10
    10011 hisk11
    10012 hisk12
    [root@linux-node1 test]#
  • 相关阅读:
    两个链表的第一个公共节点(Python and C++解法)
    第一个只出现一次的字符(Python and C++解法)
    丑数(Python and C++解法)
    最长不含重复字符的子字符串(Python and C++解法)
    礼物的最大值(Python and C++解法)
    把数字翻译成字符串(Python and C++解法)
    连续子数组的最大和(Python and C++解法)
    最小的k个数(Python and C++解法)
    数组中出现次数超过一半的数字(Python and C++解法)
    字符串的排列(Python and C++解法)
  • 原文地址:https://www.cnblogs.com/syavingcs/p/7286237.html
Copyright © 2011-2022 走看看