How can you transform a text file (plain text or HTML) or print-format file (PS or PDF) to bind it as a book using shell commands? That is, how do you create a print-format file which orders pages into signatures so that in the simple case where the number of pages is divisible by 4 per signature, pages 1, 2, N-1 and N are on the first sheet (1 and N on the same side of the sheet), 3, 4, N-3 and N-2 on the next, etc, and the next signature is equal size and starts at page N+1? It could be done by careful manipulation using pdftk or similar tools, but hopefully there are already shell tools which do this reliably and without having to for example know in advance the number of pages which will be produced or the optimum signature size.
There's already a guide using Scribus, but it involves a lot of manual steps.

