@matigo Laphroaig Lore [thewhiskyexchange.com], perhaps? Not a bad one to drown in, really.
// @streakmachine
@matigo Laphroaig Lore [thewhiskyexchange.com], perhaps? Not a bad one to drown in, really.
// @streakmachine
@jws All the Stackoverflow questions I read mentioned both sed and tr. Can't remember why I chose sed, other than that one of the posters wrote the command out in full, so I just C&Pd it into my script.
@JeremyCherfas I've only just started myself, for the same reason that you would benefit for them — time invested now is a lot of time saved in the future. All of my scripts to this point have been either for Handbrake or file renaming, which begins with for f in ./*; do (do everything below on every file in the current directory) and ends with done. "if" statements go well with that kind of script, as does a working knowledge of the basic command line tools like awk, sed, cut, grep, cp, mv, rm.
// @jws
@JeremyCherfas Noted. It seems strangely complicated to automate pandoc compared to some other tools — almost as if it weren't designed to be called in scripts.
// @jws
@jws That would work, but, if I understand your post correctly, would get messy if I ever decided to add something in the middle of the sequence — I'd have to rename all the existing files, and that goes against the LaTeX idea as well (i.e. headers are numbered automatically based on order of appearance). The aim of writing this script is to have it usable for everything I do from now on involving pandoc, so it seems like having a contents.txt that acts as the input for the commands is probably the best approach.
I've had a look for ideas from others who've scripted for pandoc and the closes I can find is pandoc-include [hackage.haskell.org], but that needs another installation, which means one more thing to remember when using the script on another computer.
Essay due in just over a week and, of course, I spend the first night writing up a plan and writing a (future-proofed) script so that I'll be able to generate the PDF painlessly.
The difficulty lay in figuring out that pandoc won't support taking a list of input files: those files must be specified in the command itself. This is unlike wc, which will take --files0-from=contents.txt (where contents.txt contains each file to be operated on on one line).
So the solution: define variable INPUT=$(sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' <contents.txt) (this replaces newlines — required by wc — with spaces, required by pandoc), then pandoc … -f "$INPUT" -t '"$EXAMNUMBER"_"$WORDCOUNT"words.pdf' (the university specifies that all submitted files must be named with only the exam number and word count).