美文网首页
MacOS split 命令拆分文件

MacOS split 命令拆分文件

作者: CHMAX | 来源:发表于2022-10-18 18:10 被阅读0次

一、常用拆分

  1. 按行拆分
# 拆分文件为指定行数
$ split -d -l 10000 -a 2 file.txt out_

$ ll
-rw-r--r--    1 xxxx  staff   369K 10 18 17:34 file.txt
-rw-r--r--    1 xxxx  staff    68K 10 18 17:44 out_00
-rw-r--r--    1 xxxx  staff    68K 10 18 17:44 out_01
-rw-r--r--    1 xxxx  staff    68K 10 18 17:44 out_02
-rw-r--r--    1 xxxx  staff    68K 10 18 17:44 out_03
-rw-r--r--    1 xxxx  staff    68K 10 18 17:44 out_04
-rw-r--r--    1 xxxx  staff    27K 10 18 17:44 out_05
  1. 按大小拆分
# 拆分文件为指定大小
$ split -d -b 100K -a 1 file.txt out_

$ ll
-rw-r--r--    1 xxxx  staff   369K 10 18 17:34 file.txt
-rw-r--r--    1 xxxx  staff   100K 10 18 17:42 out_0
-rw-r--r--    1 xxxx  staff   100K 10 18 17:42 out_1
-rw-r--r--    1 xxxx  staff   100K 10 18 17:42 out_2
-rw-r--r--    1 xxxx  staff    69K 10 18 17:42 out_3
  1. 按数拆分
# 拆分文件为指定数量
$ split -d -n 6 -a 1 file.txt out_

$ ll
-rw-r--r--    1 xxxx  staff   369K 10 18 17:34 file.txt
-rw-r--r--    1 xxxx  staff    62K 10 18 17:48 out_0
-rw-r--r--    1 xxxx  staff    62K 10 18 17:48 out_1
-rw-r--r--    1 xxxx  staff    62K 10 18 17:48 out_2
-rw-r--r--    1 xxxx  staff    62K 10 18 17:48 out_3
-rw-r--r--    1 xxxx  staff    62K 10 18 17:48 out_4
-rw-r--r--    1 xxxx  staff    62K 10 18 17:48 out_5

二、参数说明

     -d      使用数字代替字母作为后缀。

     -l 行数
             按行数拆分。

     -b 大小[K|k|M|m|G|g]
             按大小拆分。单位:Kk -> KB,Mm -> MB,Gg -> GB。

     -n 个数
             按个数拆分。

     -a 后缀长度
             使用指定的后缀长度。

三、参考详细

NAME
     split – split a file into pieces

SYNOPSIS
     split -d [-l line_count] [-a suffix_length] [file [prefix]]
     split -d -b byte_count[K|k|M|m|G|g] [-a suffix_length] [file [prefix]]
     split -d -n chunk_count [-a suffix_length] [file [prefix]]
     split -d -p pattern [-a suffix_length] [file [prefix]]

DESCRIPTION
     The split utility reads the given file and breaks it up into files of 1000 lines each (if no options are
     specified), leaving the file unchanged.  If file is a single dash (‘-’) or absent, split reads from the
     standard input.

     The options are as follows:

     -a suffix_length
             Use suffix_length letters to form the suffix of the file name.

     -b byte_count[K|k|M|m|G|g]
             Create split files byte_count bytes in length.  If k or K is appended to the number, the file is
             split into byte_count kilobyte pieces.  If m or M is appended to the number, the file is split
             into byte_count megabyte pieces.  If g or G is appended to the number, the file is split into
             byte_count gigabyte pieces.

     -d      Use a numeric suffix instead of a alphabetic suffix.

     -l line_count
             Create split files line_count lines in length.

     -n chunk_count
             Split file into chunk_count smaller files.  The first n - 1 files will be of size (size of file /
             chunk_count ) and the last file will contain the remaining bytes.

     -p pattern
             The file is split whenever an input line matches pattern, which is interpreted as an extended
             regular expression.  The matching line will be the first line of the next output file.  This
             option is incompatible with the -b and -l options.

相关文章

  • MacOS split 命令拆分文件

    一、常用拆分 按行拆分 按大小拆分 按数拆分 二、参数说明 三、参考详细

  • linux split

    split 能根据行或大小拆分指定文件。 语法: split [OPTION]... [INPUT [PREFIX...

  • linux 日志分割

    使用split命令,将日志文件分割成固定字节大小的文件 使用split命令,将日志文件按照固定行数分割

  • Linux命令之文件管理 (三十七)

    Linux split命令 Linux split命令用于将一个文件分割成数个。 该指令将大文件分割成较小的文件,...

  • linux split拆分文件

    http://c.biancheng.net/linux/split.html 15 分钟之后,我要去朋友家聚会。...

  • 2018-11-08 文件切割命令 split 使用记录

    某些文件,体积大了不方便打开,可以用 split 命令来切割成小文件。 split命令有两种方式: 1. 指定行数...

  • TCL 常用命令

    TCL 文件测试: 文件路径、文件名 split 命令: 正则表达式: regexp 命令: 高级正则表达式:

  • 大数据||MapReduce之wordcount处理过程

    文件分割 将文件拆分成splits,由于测试用的文件较小,所以每个文件为一个split,并将文件按行分割形成

  • linux常用命令

    stat 命令 du命令:M的方式查看文件大小 wc命令:统计文本 split命令:分割分拣 free 命令:查看...

  • MongoDB 拆分字段 split

    1.$split $split是aggregate的管道操作符,用于字段拆分基础语法:{ $split: [ ,...

网友评论

      本文标题:MacOS split 命令拆分文件

      本文链接:https://www.haomeiwen.com/subject/quhszrtx.html