splite指令

    最近经常要更新程序到不同环境,打包成tar.gz包后发送,因为包太大要传输很久,偶尔异常中断就白等了。还好,搜到了split指令。

先看看其帮助指示:

[root@localhost similarity]# split --help
用法:split [选项]... [输入 [前缀]]
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default
size is 1000 lines, and default PREFIX is 'x'.  With no INPUT, or when INPUT
is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
  -a, --suffix-length=N   generate suffixes of length N (default 2)
      --additional-suffix=SUFFIX  append an additional SUFFIX to file names
  -b, --bytes=SIZE        put SIZE bytes per output file
  -C, --line-bytes=SIZE   put at most SIZE bytes of lines per output file
  -d, --numeric-suffixes[=FROM]  use numeric suffixes instead of alphabetic;
                                   FROM changes the start value (default 0)
  -e, --elide-empty-files  do not generate empty output files with '-n'
      --filter=COMMAND    write to shell COMMAND; file name is $FILE
  -l, --lines=NUMBER      put NUMBER lines per output file
  -n, --number=CHUNKS     generate CHUNKS output files; see explanation below
  -u, --unbuffered        immediately copy input to output with '-n r/...'
      --verbose         在每个输出文件打开前输出文件特征
      --help            显示此帮助信息并退出
      --version         显示版本信息并退出

SIZE is an integer and optional unit (example: 10M is 10*1024*1024).  Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

CHUNKS may be:
N       split into N files based on size of input
K/N     output Kth of N to stdout
l/N     split into N files without splitting lines
l/K/N   output Kth of N to stdout without splitting lines
r/N     like 'l' but use round robin distribution
r/K/N   likewise but only output Kth of N to stdout

有点长,先捡常用的说。

-b 后面跟要分割的每个包的大小,可以用K、M、G等单位,进制是1024的;也可以跟KB、MB单位,进制是1000的。

-d 使用该参数,表明分割后的包后缀名是数字形式,若不加,后缀名默认是a、b、c、d....

-a  可跟两个参数:

      1,后面跟数字,表示后缀名的长度,如 -a  2 ,则后缀名是aa、ab、ac...,若结合-d参数,后缀名则是01、02、03....

      2,后面跟字符串,表示后缀名的名称,如-a test_2018,则分割后的包名称是test_2018a,test_2018b。。。若不加该参数,切包后的包名称是xa、xb、xc、xd....

来几个例子:

[root@localhost similarity]# ll
总用量 6225300
-rw-r--r-- 1 root root 6374705603 12月  2 21:08 hello.tar.gz

[root@localhost similarity]# split -b 500M -d hello.tar.gz  
[root@localhost similarity]# ll
总用量 12450600
-rw-r--r-- 1 root root 6374705603 12月  2 20:53 hello.tar.gz
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x00
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x01
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x02
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x03
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x04
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x05
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x06
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x07
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x08
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x09
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x10
-rw-r--r-- 1 root root  524288000 12月  2 20:57 x11
-rw-r--r-- 1 root root   83249603 12月  2 20:57 x12


[root@localhost similarity]# split -b 500M hello.tar.gz -d -a 2 hello-split
[root@localhost similarity]# ll
总用量 12450600
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split00
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split01
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split02
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split03
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split04
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split05
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split06
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split07
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split08
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split09
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split10
-rw-r--r-- 1 root root  524288000 12月  2 21:44 hello-split11
-rw-r--r-- 1 root root   83249603 12月  2 21:44 hello-split12
-rw-r--r-- 1 root root 6374705603 12月  2 21:08 hello.tar.gz

分割后要汇总,用cat指令

[root@localhost similarity]# cat ai-similarity-service-20181202-split* > ai-similarity-service-20181202.tar.gz

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值