Este faz assim, embaralha cada capítulo e pega linhas "lineswanted" do resultado para finalmente armazená-lo nos dois metades:
#!/bin/bash
lineswanted=300
infile="full"
half1="half1"
half2="half2"
# Build chapterlist 0 1 2 3 ....
chapterlist=""
for (( i=0 ; i<100; i=i+1 )) ; do
chapterlist="$chapterlist $i"
done
# shuffle chapterlist
randomchapterlist="'shuf -e $chapterlist'"
rm -f "$half1" "$half2"
i=0
for chapter in $randomchapterlist ; do
if [ $i -lt 50 ] ; then
egrep ".*\ $chapter$" "$infile" | shuf | head -n $lineswanted >> "$half1"
else
egrep ".*\ $chapter$" "$infile" | shuf | head -n $lineswanted >> "$half2"
fi
i=$(( i+1 ));
done