我正在编写一个包装器shell脚本来执行以下操作:
假设我无法访问Pdf Reader的源代码,脚本将如何知道它到了.pdf的末尾?
答案 0 :(得分:0)
DELAY=3
loc="/2/Downloads/"
find "$loc"* -type f | sort -h|egrep 'djvu|pdf$'>.delete;
n=`wc -l <.delete`
while [ "$n" -gt 0 ];
do
if [ -f pagenumber ]
then
i=`more pagenumber` # you can maniupulate it to make a filename which can store individual pagenumber inisilization ;)
else
i=0;
fi
a=$(pdftk "`tail -"$n" .delete | head -1`" dump_data|more|egrep -i numberofpages|egrep -io '[0-9]*')
while [ $i -lt $a ] ;
do
evince -i "$i" "`tail -"$n" .delete | head -1`" & sleep "$DELAY"s;i=$(($i+1));echo page number $i;
echo $i > pagenumber
done || gnome-open "`tail -"$n" .delete | head -1`"
sleep 10s
rm pagenumber
n=$(($n-1))
done