split
是一个标准实用程序,包含在coreutils
包中。该软件包具有“必需”优先级(并标记为“必需”),因此正常的 Debian 安装将拥有它。
我猜您的服务器正在运行BusyBox实用程序。BusyBox 是一套实用程序,专为磁盘空间或内存很小的系统而设计。它的许多功能都是可选的,而 Debian 的普通 BusyBox 软件包不包含该split
实用程序(大概是因为它不经常使用)。
您可以使用split
该head
实用程序和一些 shell 编程来模拟一些用途。这是一个快速而肮脏的脚本,用于将输入拆分为固定大小的块:
#!/bin/sh
i=1000000001 # Below we'll strip away the leading 1; this is
# a trick to have leading zeroes in the file names.
prefix=$1 # The files will be called ${prefix}000000001, etc.
chunk_size=$2 # in bytes, or 42k or 42m for kB and MB respectively
while
head -q -c "$chunk_size" >"$prefix${i#1}"
[ -s "$prefix${i#1}" ] # Stop when we make an empty chunk.
do
i=$((i+1))
done
rm "$prefix${i#1}" # Remove the last, zero-sized chunk.
Run Code Online (Sandbox Code Playgroud)
将该脚本存储为simple_split
. 用法示例:
tar -cf - /big/dir | simple_split foo.tar- 1m
Run Code Online (Sandbox Code Playgroud)
此命令创建1MB大小的文件叫foo.tar-000000001
,foo.tar-000000002
等你可以用它们组装cat
; 请注意,由于数字的固定宽度格式,文件按名称的词汇顺序排列。
cat foo.tar-????????? | tar -tf -
Run Code Online (Sandbox Code Playgroud)