I need to find LaTeX Generated PDF files because I want to find those files made by me. I think find could possibly work here.

OS X El-Capitan

I run Ulrich's proposal find BitTorrentSync/ -exec pdfinfo {} + |grep pdftex but I get

find: pdfinfo: No such file or directory
find: pdfinfo: No such file or directory

where the problem is that I do not have pdfinfo yet in my system.

L.Levrel's proposal. I run gfind -name '*.pdf' | gxargs ggrep -al '^/Producer (pdfTeX' where I use GNU's products but I get in OS X El-Capitan

gxargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
ggrep: cademic: invalid context length argument

Ubuntu 16.04

I cannot run Ulrich's proposal because of the bug here. L.Levrel's first proposal does not work but it works with xargs -0

find -name '*.pdf' | xargs -0 grep -al '^/Producer (pdfTeX'

How can you find LaTeX generated PDF files?

  • The output of pdfinfo will include the creator (software), depending on your workflow that would include strings like "pdftex" or "dvipdf" or "dvips". So, vaguely, first find all pdfs, -exec pdfinfo on each and inspect its output with grep? – Ulrich Schwarz May 21 '16 at 12:57
  • Install pdfinfo – casey May 21 '16 at 15:57
  • What operating system are you using? – fd0 May 21 '16 at 17:44
  • @fd0 I am using OS X El-Capitan and Ubuntu 16.04. See the body for the clarifications. – Léo Léopold Hertz 준영 May 21 '16 at 18:59

Based on L.Levrel response, using the tools supplied in OS X (this should also work in Ubuntu).

find . -type f -name '*.pdf' -exec grep -alE '/Producer \(pdfTeX|/Producer\(pdfTeX' {} +

You can look at the "/Producer" line:

find -name '*.pdf' | xargs grep -al '^/Producer (pdfTeX'

or with double quotes

find -name '*.pdf' | xargs grep -al "^/Producer (pdfTeX"

or with null-separated list of files

find -name '*.pdf' -print0 | xargs -0 grep -al '^/Producer (pdfTeX'
  • Unexpected token ')'? There's no ')' in the command. – L. Levrel May 21 '16 at 14:29
  • 1
    My output is the expected list of files. The fact you have to call gfoo for the GNU foo makes me think you're not on Linux. What OS then? Specify it in your question and/or tags. – L. Levrel May 21 '16 at 17:39
  • I am using OS X El-Capitan and Ubuntu 16.04. I cannot understand why GNU products do not work in OS X. – Léo Léopold Hertz 준영 May 21 '16 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.