30 lines
506 B
Bash
Executable File
30 lines
506 B
Bash
Executable File
#!/bin/bash
|
|
source shared.sh
|
|
|
|
if [ "$1" == "" ]; then
|
|
echo "usage: $0 <file>"
|
|
exit;
|
|
fi
|
|
|
|
mkdir -p out
|
|
rm out/*
|
|
|
|
echo ".ll $LL" > out/header
|
|
cat "$1" | sed 's/\./\\\&./g' > out/text
|
|
echo ".sp 0" > out/footer
|
|
cat out/header out/text out/footer | nroff -Tascii > out/render
|
|
|
|
cline=0
|
|
page=1
|
|
while IFS="" read -r p || [ -n "$p" ]
|
|
do
|
|
cline=$(($cline + 1))
|
|
if [ $cline -eq $PL ]; then
|
|
page=$(($page + 1))
|
|
cline=0
|
|
fi
|
|
printf '%s\n' "$p" >> "out/out$page.txt"
|
|
done < out/render
|
|
|
|
echo "Created $page pages."
|