操作步骤
(1)打包文件:
tar -cvf 20190816.tar 20190816
(2)分割文件:
#例子1
split -b 3G -d -a 1 20190816.tar 20190816.tar.
#例子2
split -b 40000K -d -a 1 go_1.7.tar.gz go_1.7.tar.gz.
# 例子3
split -b 40m -d -a 2 ISTP.tar ISTP.tar.
执行后的效果
-rw-r--r-- 1 root root 4194304000 May 20 14:00 cm-11.tar.gz.0
-rw-r--r-- 1 root root 4194304000 May 20 14:02 cm-11.tar.gz.1
-rw-r--r-- 1 root root 4194304000 May 20 14:03 cm-11.tar.gz.2
-rw-r--r-- 1 root root 4194304000 May 20 14:05 cm-11.tar.gz.3
-rw-r--r-- 1 root root 4194304000 May 20 14:06 cm-11.tar.gz.4
-rw-r--r-- 1 root root 4194304000 May 20 14:08 cm-11.tar.gz.5
-rw-r--r-- 1 root root 4194304000 May 20 14:09 cm-11.tar.gz.6
-rw-r--r-- 1 root root 2256379886 May 20 14:10 cm-11.tar.gz.7
参数解析
-b 3G 表示设置每个分割包的大小,单位还是可以k
-d "参数指定生成的分割包后缀为数字的形式
-a x来设定序列的长度(默认值是2),这里设定序列的长度为1
(3)合并分割后压缩包,并解压
cat 20190816.tar.* >new_20190816.tar
tar-xvf new_20190816.tar
split 命令详解
Mandatory arguments to long options are mandatory for short options too.
-a, --suffix-length=N use suffixes of length N (default 2)
-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 use numeric suffixes instead of alphabetic
-l, --lines=NUMBER put NUMBER lines per output file
--verbose print a diagnostic to standard error just
before each output file is opened
--help display this help and exit
--version output version information and exit
SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg.
-b 的参数可以是 数字,也可以是K (1 KB),或者m (1 mb)
例子3
split -b 40m -d -a 2 ISTP.tar ISTP.tar.
参考链接
https://blog.csdn.net/weixin_28755447/article/details/116555214
参考工具
字节计算器
https://calc.itzmx.com/