我想按字节分割文件,同时通过
保持完整行split -C <bytes> filename
但是,默认拆分不接受-C
split: illegal option -- C
usage: split [-a sufflen] [-b byte_count] [-l line_count] [-p pattern]
[file [prefix]]
我brew install coreutils
,looks like it should support what I want。
如何更改拆分以使用coreutils?
答案 0 :(得分:3)
brew install coreutils
将安装以&#39; g&#39;为前缀的命令默认情况下。因此,如果您输入split
,gsplit
应该可用。您可以使用选项--with-default-names
安装包,以正常名称安装命令。
有关详细信息,请参阅https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
答案 1 :(得分:0)
发现它!
brew info coreutils
...
==> Caveats
All commands have been installed with the prefix 'g'.
所以它只是gsplit -C $BYTES filename
答案 2 :(得分:0)
请转到文件的路径并执行以下命令 分割-b 500m inputFile output_files.split.txt
示例
split -b 500m sample.txt output_files.split.txt
答案 3 :(得分:0)
--with-default-names
已从brew中删除,因此,如果您需要使用正常名称运行一个命令,则需要在路径中添加一些内容。见下文
brew info coreutils
...
==> Caveats
Commands also provided by macOS have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"