bash seq question

It's not often I have to assemble larger numbered documents. I usually use this little script. enscript -L1 -F --header-font=Times-Roman12 -b '||$%' -o- < <(for i in $(seq "$(pdftk "$1" dump_data | grep "Num" | cut -d":" -f2)"); do echo; done) | ps2pdf - | pdftk "$1" multistamp - output "${1%.pdf}-numbered.pdf" I tried it on this .. Linux HECTOR 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux and got this .. seq: invalid floating point argument: 162 162 pages with no numbers. Could this be because the pdf's were generated in M$? Thanks in advance. Russell

Hi Russell -
It's not often I have to assemble larger numbered documents. I usually use this little script.
enscript -L1 -F --header-font=Times-Roman12 -b '||$%' -o- < <(for i in $(seq "$(pdftk "$1" dump_data | grep "Num" | cut -d":" -f2)"); do echo; done) | ps2pdf - | pdftk "$1" multistamp - output "${1%.pdf}-numbered.pdf"
I've used something similar myself many times. Your grep command should be: grep '^PageMediaNumber:' as you're also matching 'PageLabelNumStyle' content. These aren't numeric values, and will cause seq to fail. It may also be possible for PageMediaNumber to return something like '1-1'. Personally, I'd use pdfinfo rather than pdftk … dump_data to do page counts, as its Pages field is always numeric. Bates Numbering is fun! cheers, Stewart

I had to resort to analogue to get the docs out. You remember, print the numbers on the pages, then run them through for the data. Curse u seq: invalid floating point argument: 1 This one liner was my magic bullet a few short kernel updates ago. Tunnel in get the job done right and exit. Kind of like Robert De Nero in Brazil but without the yankee screwdriver and abseiling gear. Williams suggestions also threw seq: invalid args. Thanks both. Russell On Feb 2, 2017 7:22 PM, "Stewart C. Russell via talk" <talk@gtalug.org> wrote:
Hi Russell -
It's not often I have to assemble larger numbered documents. I usually use this little script.
enscript -L1 -F --header-font=Times-Roman12 -b '||$%' -o- < <(for i in $(seq "$(pdftk "$1" dump_data | grep "Num" | cut -d":" -f2)"); do echo; done) | ps2pdf - | pdftk "$1" multistamp - output "${1%.pdf}-numbered.pdf"
I've used something similar myself many times. Your grep command should be:
grep '^PageMediaNumber:'
as you're also matching 'PageLabelNumStyle' content. These aren't numeric values, and will cause seq to fail. It may also be possible for PageMediaNumber to return something like '1-1'.
Personally, I'd use pdfinfo rather than pdftk … dump_data to do page counts, as its Pages field is always numeric.
Bates Numbering is fun!
cheers, Stewart
--- Talk Mailing List talk@gtalug.org https://gtalug.org/mailman/listinfo/talk

On 2017-02-06 01:36 PM, Russell Reiter wrote:
I had to resort to analogue to get the docs out. You remember, print the numbers on the pages, then run them through for the data.
Ah, that's annoying. Your script does seem to be a variant of this, which seems to work: #!/bin/bash # from http://stackoverflow.com/a/9033109/377125 input="$1" output="${1%.pdf}-header.pdf" pagenum=$(pdftk "$input" dump_data | grep "NumberOfPages" | cut -d":" -f2) enscript -L1 --header='||Page $% of $=' --output - < <(for i in $(seq "$pagenum"); do echo; done) | ps2pdf - | pdftk "$input" multistamp - output $output Stewart

On Feb 8, 2017 5:48 AM, "Stewart C. Russell via talk" <talk@gtalug.org> wrote:
On 2017-02-06 01:36 PM, Russell Reiter wrote:
I had to resort to analogue to get the docs out. You remember, print the numbers on the pages, then run them through for the data.
Ah, that's annoying.
Your script does seem to be a variant of this, which seems to work:
#!/bin/bash # from http://stackoverflow.com/a/9033109/377125 input="$1" output="${1%.pdf}-header.pdf" pagenum=$(pdftk "$input" dump_data | grep "NumberOfPages" | cut -d":" -f2) enscript -L1 --header='||Page $% of $=' --output - < <(for i in $(seq "$pagenum"); do echo; done) | ps2pdf - | pdftk "$input" multistamp - output $output
Thanks, I'll try that out next time. Fooling around with Gimp layers shows some promising results, but that's all GUI. It's not quite the magic bullet I had going for me before. Cheers Russell
Stewart --- Talk Mailing List talk@gtalug.org https://gtalug.org/mailman/listinfo/talk

On Feb 7, 2017 4:48 PM, "Stewart C. Russell via talk" <talk@gtalug.org> wrote:
On 2017-02-06 01:36 PM, Russell Reiter wrote:
I had to resort to analogue to get the docs out. You remember, print the numbers on the pages, then run them through for the data.
Ah, that's annoying.
Your script does seem to be a variant of this, which seems to work:
#!/bin/bash # from http://stackoverflow.com/a/9033109/377125 input="$1" output="${1%.pdf}-header.pdf" pagenum=$(pdftk "$input" dump_data | grep "NumberOfPages" | cut -d":" -f2) enscript -L1 --header='||Page $% of $=' --output - < <(for i in $(seq "$pagenum"); do echo; done) | ps2pdf - | pdftk "$input" multistamp - output $output
Hey. It didn't work the first time but I joined the lines into one bullet and it did. Go figure that one?! I don't know what I find to be more cryptic, shaking hands with a mason, or bash quoting and syntax. I still have to figure out how to led the stamp baseline so it doesn't bork the original doc header text but I'm much closer to being where I was. Thanks Russell
Stewart --- Talk Mailing List talk@gtalug.org https://gtalug.org/mailman/listinfo/talk

| From: Russell Reiter via talk <talk@gtalug.org> | I don't know what I find to be more cryptic, shaking hands with a mason, or | bash quoting and syntax. A problem in analytic philosophy <https://en.wikipedia.org/wiki/Use%E2%80%93mention_distinction>

On Feb 10, 2017 1:55 PM, "D. Hugh Redelmeier via talk" <talk@gtalug.org> wrote: | From: Russell Reiter via talk <talk@gtalug.org> | I don't know what I find to be more cryptic, shaking hands with a mason, or | bash quoting and syntax. A problem in analytic philosophy <https://en.wikipedia.org/wiki/Use%E2%80%93mention_distinction> Nice link, thanks. Use and mention, the universal problem of transliteration. Also appears to be the heart of the fuzzy TLS correction a while ago. The hard rule says answer yes or no "correctly", to gain trusted access, however you send bug and fuzzily enough you gained trust. In literature, I believe you put the comma inside the marks quoting an object as part of a sentence. I quoted incorrectly above to help " bash," if necessary. --- Talk Mailing List talk@gtalug.org https://gtalug.org/mailman/listinfo/talk

On Thu, Feb 02, 2017 at 06:06:45PM -0500, Russell Reiter via talk wrote:
It's not often I have to assemble larger numbered documents. I usually use this little script.
enscript -L1 -F --header-font=Times-Roman12 -b '||$%' -o- < <(for i in $(seq "$(pdftk "$1" dump_data | grep "Num" | cut -d":" -f2)"); do echo; done) | ps2pdf - | pdftk "$1" multistamp - output "${1%.pdf}-numbered.pdf"
I can't read this. Re-writing... enscript -L1 -F --header-font=Times-Roman12 -b '||$%' -o- < <( for i in $( seq "$(pdftk "$1" dump_data | grep "Num" | cut -d":" -f2)" ); do echo done ) | ps2pdf - | pdftk "$1" multistamp - output "${1%.pdf}-numbered.pdf" Maybe you meant, seq $(pdftk "$1" dump_data | grep Num | cut -d: -f2) seq takes number arguments, so you don't need to quote something that shouldn't be there in the first place. Also, you are printing empty lines using 'echo'. Process substitution will not like it.
I tried it on this ..
Linux HECTOR 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux
and got this ..
seq: invalid floating point argument: 162
162 pages with no numbers.
Could this be because the pdf's were generated in M$?
Thanks in advance.
Russell
--- Talk Mailing List talk@gtalug.org https://gtalug.org/mailman/listinfo/talk
participants (4)
-
D. Hugh Redelmeier
-
Russell Reiter
-
Stewart C. Russell
-
William Park