我如何在 mac 中拆分文件然后将其连接 Windows (例如:使用 split 和 cat)?

How can I split file in mac and then concat it Windows (e.g: using split and cat)?

我尝试使用以下命令拆分文件 Mac:

split -b 20mb myFile.zip

然后我得到一些以 x:

开头的文件
xaa xab

我可以使用 cat 终端命令恢复 Mac 上的文件:

cat xaa xab > myFile.zip

但是它无法在 Windows 上执行 cat 命令。 有什么可行的解决方案吗?

下面的批处理脚本可以满足您的需要。按 batchfile.bat x myFile.zip 使用它,它循环遍历以指定前缀 x 开头的所有文件,并使用 type:

将它们附加到结果文件 myFile.zip
@echo off

set INVARGS=0
if [%1] == [] set INVARGS=1
if [%2] == [] set INVARGS=1
if %INVARGS% == 1 (
   echo Usage: %0 ^<file_prefix^> ^<result_file^>
   goto eof
)

set "prefix=%~1"
set "resFile=%~2"

rem create new empty file in directory of batch file: %~dp0
break>"%resFile%"
rem loop through all output line of the dir command, unset delimns
rem so that space will not separate
for /F "delims=" %%a in ('dir "%prefix%*" /b /s /a-d') do (
   rem don't use the result file
   if not [%%a] == [%resFile%] (
      rem append the output to file
      type "%%a">>"%resFile%"
   )
)

:eof