3 ms·
#! /bin/bash pdf_one="$1" pdf_two="$2" text_one=$(mktemp) text_two=$(mktemp) pdftotext "$pdf_one" "$text_one" pdftotext "$pdf_two" "$text_two"
by untoxicness 5y ago
#! /bin/bash
pdf_one="$1"
pdf_two="$2"
text_one=$(mktemp)
text_two=$(mktemp)
pdftotext "$pdf_one" "$text_one"
pdftotext "$pdf_two" "$text_two"
diff "$text_one" "$text_two"
- halostatue 5y agoIt is entirely possible for that to present unexpected differences because of the way that the PDF format works. One can have two different PDFs that encode the same content in two different ways and unless `pdftotext` does virtual layout and then OCR-like extraction, you might end up with jumbled text or text in different orders.
- seoaeu 5y agoWon't that fail terribly if the text has been re-flowed?
- Hello71 5y agonot only is this the first solution presented in the article, you've not even bothered to pass -layout to pdftotext or -u/-y to diff which would make this marginally workable. spaces after shebang also doesn't always work (e.g. in qemu), you don't clean up the temporary files, and the temporary files have unhelpful names.
- mdaniel 5y agoI did some research about the space after shebang and discovered that it was evidently a (bug/misunderstanding) from the autoconf "portable shell" guide that just stuck, even after being corrected in the modern manual Links for those who are similarly curious, with the 2nd link being especially fascinating: https://unix.stackexchange.com/questions/276751/is-space-allowed-between-and-bin-bash-in-shebang https://unix.stackexchange.com/questions/276751/is-space-all... https://web.archive.org/web/20170215070707/http://www.in-ulm.de/~mascheck/various/shebang/#details https://web.archive.org/web/20170215070707/http://www.in-ulm... (courtesy of one of the answers in the first link but separately interesting IMHO) I will say, I don't know if it's Stockholm Syndrome from years of writing them with the space or what, but I do find the space version nicer to read, doubly so when using the [almost obligatory on macOS] `/usr/bin/env bash` form since it makes all the participants in the shebang space delimited. I can easily see the counterargument from those misguided souls who hard-code `/bin/bash` that the non space version is their muscle memory and requires less mental parsing