shell - 如何使用数字后缀分割文件

标签 shell command-line ssh command

我正在使用以下命令来分割文件。它应该每 50,000 行分割一次并使用 4 位数字后缀。该文件大约有 1.4 亿行。

split -d -l -n 4 50000 domains.xml domains_

但是当我运行时,我收到此错误:

split: -n: invalid number of lines
Try `split --help' for more information.

正确的命令是什么?

最佳答案

因为 GNU split 的主要帮助说:

Usage: /usr/gnu/bin/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   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 below
  -u, --unbuffered        immediately copy input to output with '-n r/...'
      --verbose           print a diagnostic just before each
                            output file is opened
      --help     display this help and exit
      --version  output version information and exit

在我看来,您需要稍微重新组织一下您的选择:

split -a 4 -d -l 50000 domains.xml domains_

关于shell - 如何使用数字后缀分割文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14973815/

相关文章:

sql - 无法从 bash 运行 postgresql 脚本

excel - 在 Mac 上使用终端通过 Excel 打开文件

linux - Shell脚本设置执行时间

java - 执行显示控制台窗口的命令并获取进程的句柄

bash - 检查是否 SSH 提示输入密码

shell - 从文本文件读取时如何在 korn shell 中分配包含 * 的变量

file - 从包含数千个文件的主文件夹创建 A 到 Z 子文件夹

javascript - 如何从 Istanbul 尔报道中忽略 node.js 中所需的文件

windows - 尝试克隆 git repo 后 Win 控制台挂起

SSH 到防火墙后面的服务器