您的位置:首页 > 运维架构 > Linux

Linux 命令split 详解(参数详解)

2018-03-26 11:11 337 查看
在Linux上输入:split --help 或者 man 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.

默认前缀:X, 所以自己不设置时默认输出文件名:Xaa, Xab, .....
默认输出大小为 1000行
如果 没有INPUT 或者 INPUT为 "-" 则表示标准输入,如通过管道获取(下图所示)

$ zcat MOS18020001_R2.fastq.gz | split -l 8000000 -d -a 2 - MOS18020001_R2.fastq
其中 -l 表示输出文件行数,-d 表示添加数字后缀,-a 表示添加后缀长度,为2时数字为:01, 02, 03, ..., - 表示标准输入,MOS18020001_R2.fastq 为自定义的前缀

输出的文件名:MOS18020001_R2.fastq01, MOS18020001_R2.fastq02, MOS18020001_R2.fastq03

以下为各参数详解:
Mandatory arguments to long options are mandatory for short options too.
  -a, --suffix-length=N   use suffixes of length N (default 2)
       输出文件后缀长度,默认为2

  -b, --bytes=SIZE        put SIZE bytes per output file
        按照文件大小分割文件,单位:字节

一个字节 = 8位二进制数(1byte == 8bit)
ASCII码:一个英文字母(不分大小写)占一个字节的空间,一个中文汉字占两个字节的空间

UTF-8编码:一个英文字符等于一个字节,一个中文(含繁体,及中文标点)等于三个字节

Unicode编码:一个英文(含标点)等于两个字节,一个中文(含繁体,及中文标点)等于两个字节
  -d, --numeric-suffixes  use numeric suffixes instead of alphabetic

添加数字后缀(因为默认添加的是字母后缀,所有要想加数字需要自己添加)
  -l, --lines=NUMBER      put NUMBER lines per output file

按照行数分割文件默认1000行一个文件
      --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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息