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变量及简单数据类型
    python函数小案例
    python字符串和列表小案例
    python循环输出
    Jmeter测试工具
    操作系统-进程管理~
    操作系统~
    组成原理第一章笔记~
    分时间段(年份或月份)统计,没有数字补0 Java(替代 MYSQL) 做法
    组成原理复习概略
  • 原文地址:https://www.cnblogs.com/syavingcs/p/7286237.html
Copyright © 2011-2022 走看看