pdftk: edit PDF file in-place
in your operation bash overwrite in.pdf file before call pdftk. You can't do it that way. I would recommend something like
pdftk in.pdf cat 1-endright output in-new.pdf && mv in-new.pdf in.pdf
This command also protect you when converting fail - file would not be overwriten.
Use moreutils
sponge
for this:
pdftk in.pdf cat 1-endright output - | sponge in.pdf
One bug I've found is that pdftk
doesn't always return non-zero on error, meaning that in.pdf
may be wiped (sponge
doesn't wipe if zero exit status).