Last active
January 12, 2017 14:17
-
-
Save courtneymyers/53ae9df7dba7eeff5a23c83a7e132f27 to your computer and use it in GitHub Desktop.
Bash script for searching for specific terms found within PDFs in the current directory. Relies on the 'pdftotext' command line utility.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#echo "This script will search PDFs in this directory. Enter search term:" | |
#read term | |
#echo "Results found for \"${term}\":" | |
#find . -name '*.pdf' -exec sh -c "pdftotext '{}' - | grep --label='{}' --color --with-filename --line-number --ignore-case '${term}'" \; | |
# check for input arguments | |
if [ $# -eq 0 ] ; then | |
echo "You must enter a search term." | |
exit 1 | |
fi | |
echo "Searching PDFs in this directory for \"$1\"..." | |
find . -name '*.pdf' -exec sh -c "pdftotext '{}' - | grep --label='{}' --color --with-filename --line-number --ignore-case '$1'" \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment