Linux split拆分文件

Linux split拆分文件

2016-10-09 19:17 by pursuer.chen, 23915 阅读, 0 评论, 收藏编辑

介绍

split可以将一个大文件拆分成指定大小的多个文件,并且拆分速度非常的快,拆分一个1G大小的文件花费不到1S的时间,如果手工在windows上面进行操作估计得卡死。

 

 

选项

复制代码
Usage: split [OPTION]... [INPUT [PREFIX]]
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   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 just before each
                            output file is opened
      --help     display this help and exit
      --version  output version information and exit

SIZE may be (or may be an integer optionally followed by) one of following:
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. 可以用后缀指定其它的单位

Report split bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'split invocation'
复制代码

 

实例

复制代码
[root@localhost test]# more test
a
b
c
d
e
f
g
复制代码
1.根据行拆分

每3行拆分成一个文件,拆分后的文件名以name开头,以数字作为后缀后缀长度为1

split -l 3 test -d -a 1 name
复制代码
[root@localhost test]# ll
total 16
-rw-r--r--. 1 root root  6 Oct  9 19:12 name0
-rw-r--r--. 1 root root  6 Oct  9 19:12 name1
-rw-r--r--. 1 root root  2 Oct  9 19:12 name2
-rw-r--r--. 1 root root 14 Oct  9 19:07 test
复制代码
2.按字节进行拆分

每三个字节拆分成一个文件,默认不加单位就是字节,也可以带单位比如KB,MB等

split -b 3 test -d -a 1 new
复制代码
[root@localhost test]# ls -l new*
-rw-r--r--. 1 root root 3 Oct  9 19:13 new0
-rw-r--r--. 1 root root 3 Oct  9 19:13 new1
-rw-r--r--. 1 root root 3 Oct  9 19:13 new2
-rw-r--r--. 1 root root 3 Oct  9 19:13 new3
-rw-r--r--. 1 root root 2 Oct  9 19:13 new4
复制代码

 

总结

 spit命令很实用,比如导入数据时将文件进行拆分并发导入会快很多。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值