to convert pdf to text use pdftotext from poppler-utils:

sudo apt-get install poppler-utils

this function uses find to locate all *.pdf files in the current directory, converts pdf to text and counts appearance of the search term in the file:

spdf () { find . -name "*.pdf" -print0| while read -d $'' file; do co=$(pdftotext -q "$file" - |grep -c $1); if [ $co -ne 0 ]; then echo $co - "$file" ; fi ; done }

use:

> spdf modes

will list files that contain the word “modes” and will tell you how many times it is mentioned in the file. i’m not sure but may be it just list the lines that contain the word(s).

this would be useful if you search for publications and want to see which one is more relevant. one way to find out is to see which one mentions your term the most.

for ps use

sps () { find . -name "*.ps" -print0| while read -d $'' file; do co=$(ps2txt "$file" |grep -c $1); if [ $co -ne 0 ]; then echo $co - "$file" ; fi ; done }

Advertisements