I'm trying to search multiple pdf files for a pattern using pdfgrep. The command I'm using is

pdfgrep --color always <pattern> */*.pdf > outputFile

I'm directing the output to a file, because the command produces a massive amount of output. If I then type cat outputFile I have a problem with long lines, as the following illustrates, i.e., there a gaps in the lines and some letters and words missing:

ARE249/LewandowskyEtAl_PsychSci_2016.pdf:referred to as worldview or cultural cognition—is a major                          because if an overwhelming scientific consensus cannot
ARE249/LewandowskyObenhauerGignac_PsychSci_2016_annot.pdf:referred to as worldview or cultural cognition—is a major                          because if an overwhelming scientific consensus cannot        KIRIVEXIH
ARE249/Lewandowsky_Oberauer_MotivatedRejectionofScience_2016.pdf:apparent than with climate science. The overwhelming                                and Slovic (2013). The tables in panel (a) of Figure 1
ARE249/Lewandowsky_Oberauer_MotivatedRejectionofScience_2016.pdf:    In summary, the rejection of specific scientific evi-                          in panel (b) of Figure 1. Liberals overwhelmingly arrived
ARE249/Lewandowsky_Oberauer_MotivatedRejectionofScience_2016.pdf:to decrease as a result of gun control, whereas they failed                          are motivated to reject an overwhelming scientific con-


A related problem is viewing the output file. If I pipe it to more, the output looks ok, but I'd really like to be able to scroll up and down through the output. However, if I pipe it to less I get lots of ESC's, as in

ESC[35mESC[KARE249/Kahan_VaccineRisk_2014.pdfESC[mESC[KESC[36mESC[K:ESC[mESC[Kone in the PUBLIC_HEALTH scale. The sample-wide scores on that scale reflected an ESC[01;3

An alternative would be to view outputFile through an editor, however in both vi and emacs I get output similar to the output from less.

Does anybody have any good solultions to these problems? Thanks!

  • 2
    passing -R to less should help – iruvar Nov 19 '16 at 20:31

Your Answer

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

Browse other questions tagged or ask your own question.