zoukankan      html  css  js  c++  java
  • linux系统中split命令

    1、split按文件大小拆分文件

    测试数据如下:

    [root@centos79 test]# dd if=/dev/zero bs=1M count=100 of=a.txt
    100+0 records in
    100+0 records out
    104857600 bytes (105 MB) copied, 0.0620975 s, 1.7 GB/s
    [root@centos79 test]# ll -h
    total 100M
    -rw-r--r--. 1 root root 100M Jul  5 17:17 a.txt

    2、-b参数按照大小拆分文件

    [root@centos79 test]# ls
    a.txt
    [root@centos79 test]# split -b 50M a.txt
    [root@centos79 test]# ll -h
    total 200M
    -rw-r--r--. 1 root root 100M Jul  5 17:17 a.txt
    -rw-r--r--. 1 root root  50M Jul  5 17:19 xaa
    -rw-r--r--. 1 root root  50M Jul  5 17:19 xab

    3、利用cat命令合并拆分的文件

    [root@centos79 test]# cat xaa xab > b.txt
    [root@centos79 test]# ll -h
    total 300M
    -rw-r--r--. 1 root root 100M Jul  5 17:17 a.txt
    -rw-r--r--. 1 root root 100M Jul  5 17:20 b.txt
    -rw-r--r--. 1 root root  50M Jul  5 17:19 xaa
    -rw-r--r--. 1 root root  50M Jul  5 17:19 xab
    [root@centos79 test]# md5sum *
    2f282b84e7e608d5852449ed940bfc51  a.txt
    2f282b84e7e608d5852449ed940bfc51  b.txt
    25e317773f308e446cc84c503a6d1f85  xaa
    25e317773f308e446cc84c503a6d1f85  xab

    5、给拆分后的文件增加前缀

    [root@centos79 test]# rm !(a.txt)
    [root@centos79 test]# ls
    a.txt
    [root@centos79 test]# split -b 50M a.txt sub_
    [root@centos79 test]# ls
    a.txt  sub_aa  sub_ab
    [root@centos79 test]# ll -h
    total 200M
    -rw-r--r--. 1 root root 100M Jul  5 17:17 a.txt
    -rw-r--r--. 1 root root  50M Jul  5 17:22 sub_aa
    -rw-r--r--. 1 root root  50M Jul  5 17:22 sub_ab

    6、使用-d参数给拆分后的文件指定00、01……后缀

    [root@centos79 test]# rm !(a.txt)
    [root@centos79 test]# ls
    a.txt
    [root@centos79 test]# split -b 50M a.txt sub_ -d
    [root@centos79 test]# ls
    a.txt  sub_00  sub_01
    [root@centos79 test]# ll -h
    total 200M
    -rw-r--r--. 1 root root 100M Jul  5 17:17 a.txt
    -rw-r--r--. 1 root root  50M Jul  5 17:25 sub_00
    -rw-r--r--. 1 root root  50M Jul  5 17:25 sub_01

    7、按行拆分文件

    测试数据如下:

    [root@centos79 test]# seq -f %02g 20 | sed = | sed 'N;s/
    /	/' > a.txt
    [root@centos79 test]# ls
    a.txt
    [root@centos79 test]# cat a.txt
    1       01
    2       02
    3       03
    4       04
    5       05
    6       06
    7       07
    8       08
    9       09
    10      10
    11      11
    12      12
    13      13
    14      14
    15      15
    16      16
    17      17
    18      18
    19      19
    20      20

    8、使用 -n或者 -l n进行按行拆分文件

    [root@centos79 test]# ls
    a.txt
    [root@centos79 test]# cat a.txt
    1       01
    2       02
    3       03
    4       04
    5       05
    6       06
    7       07
    8       08
    9       09
    10      10
    11      11
    12      12
    13      13
    14      14
    15      15
    16      16
    17      17
    18      18
    19      19
    20      20
    [root@centos79 test]# split -l 5 a.txt sub_ -d     ## 按5行进行拆分文件
    [root@centos79 test]# ls
    a.txt  sub_00  sub_01  sub_02  sub_03
    [root@centos79 test]# wc -l *
     20 a.txt
      5 sub_00
      5 sub_01
      5 sub_02
      5 sub_03
     40 total
    [root@centos79 test]# cat sub_00
    1       01
    2       02
    3       03
    4       04
    5       05
  • 相关阅读:
    iOS App Store审核上传应用预览视频
    mac 下常用命令(xcode常用命令,环境相关等)
    Xcode遇到的一些常见异常
    Tomcat的SSL配置keytool生成证书
    iOS Developer TODO
    Linix常用命令
    iOS&OSX系统初步了解
    Mac下安装MySQL及启动等常用命令
    Android WebView存在跨域访问漏洞(CNVD-2017-36682)介绍及解决
    HTML5 Audio/Video 标签,属性,方法,事件汇总 (转)
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14973507.html
Copyright © 2011-2022 走看看