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]#
  • 相关阅读:
    二叉树线索化。。。
    如何通过指针访问虚函数表,并且调用里面的方法
    进程间通信IPC
    什么时候该用assert
    高并发服务端分布式系统设计概要(上)
    C语言读写文件
    Linux 与 BSD 有什么不同?
    extern "C" 使用
    C语言字符数组的定义与初始化
    Linux守护进程
  • 原文地址:https://www.cnblogs.com/syavingcs/p/7286237.html
Copyright © 2011-2022 走看看