View Single Post
Old 2022-05-10, 13:38   #3
kruoli
 
kruoli's Avatar
 
"Oliver"
Sep 2017
Porta Westfalica, DE

26·17 Posts
Default

In bash:
Code:
if [ $# -ne 3 ];
then
  echo 'Usage: bash splitter.sh [in file] [out file] [number of workers]';
  exit -1;
fi;
if ls "$1."* 1> /dev/null 2>&1;
then
  echo 'Temporary files could not be created.';
  exit -2;
fi;
range=$(seq 1 $3);
if [ $? -ne 0 ];
then
  echo 'The worker count was not numerical.';
  exit -3;
fi;

for w in $range;
do
  echo "[Worker #$w]" >> "$1.tmp";
done;
cat "$1" >> "$1.tmp";
split -n r/$3 "$1.tmp" "$1.s";
cat "$1.s"* > "$2";
rm "$1."*;
kruoli is offline   Reply With Quote