我正在尝试根据我在某些页面编号上找到的字符串将tempfile.pdf与pdftk分开。那些pagenumbers在tempfile中。
n=0
prefix1="startpoint"
prefix2="stoppoint"
while read p; do
echo $p > temp
`cat temp` = prefix1$n
echo $((p-1)) > temp
`cat temp` = prefix2$n
n=$((n+1));
done < tempfile
pdftk tempfile.pdf cat $startpoint0-$stoppoint1 output $1/01-0.pdf
pdftk tempfile.pdf cat $startpoint1-$stoppoint2 output $1/02-0.pdf
pdftk tempfile.pdf cat $startpoint2-end output $1/03-0.pdf
出于某种原因,我得到这样的错误:
/usr/local/bin/skapa_digital_akt: rad 16: 1: kommandot finns inte
/usr/local/bin/skapa_digital_akt: rad 18: 0: kommandot finns inte
/usr/local/bin/skapa_digital_akt: rad 16: 6: kommandot finns inte
/usr/local/bin/skapa_digital_akt: rad 18: 5: kommandot finns inte
/usr/local/bin/skapa_digital_akt: rad 16: 13: kommandot finns inte
/usr/local/bin/skapa_digital_akt: rad 18: 12: kommandot finns inte
Error: Unexpected range end; expected a page
number or legal keyword, here:
Exiting.
Errors encountered. No output created.
Done. Input errors, so no output created.
Error: Unexpected range end; expected a page
number or legal keyword, here:
Exiting.
Errors encountered. No output created.
Done. Input errors, so no output created.
Error: Input page numbers include 0 (zero)
The first PDF page is 1 (one)
Exiting.
Errors encountered. No output created.
Done. Input errors, so no output created.
显然,变量startpoint / stoppoint设置错误。有人可以帮帮我吗?
非常感谢!
/保罗
答案 0 :(得分:1)
什么是
`cat temp` = prefix1$n
应该这样做?您应该知道:它从temp
读取命令行并执行它。
如果temp包含一行1
(而n
为== 0
),则执行的命令将为:
1 = prefix10
您可以通过在脚本上插入set -x
或使用sh -x yourscript.sh
答案 1 :(得分:0)
这有效:
n=0
while read p; do
echo $p > tempA$n
echo $((p-1)) > tempB$n
n=$((n+1));
done < tempfile
startpoint0=$(cat tempA0)
stoppoint1=$(cat tempB1)
startpoint1=$(cat tempA1)
stoppoint2=$(cat tempB2)
startpoint2=$(cat tempA2)
pdftk tempfile.pdf cat $startpoint0-$stoppoint1 output $1/01-0.pdf
pdftk tempfile.pdf cat $startpoint1-$stoppoint2 output $1/02-0.pdf
pdftk tempfile.pdf cat $startpoint2-end output $1/03-0.pdf