Advertisement
marcoshalano

searchpdf.sh

May 3rd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.38 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # The first argument is the search term. Can be more than one word but you need quotation marks.
  4. # The other terms are filenames.
  5. # TODO: Keep color from grep
  6. count=0
  7.  
  8. for i in "$@"; do
  9.   if [ $count -eq 0 ]; then
  10.     term=$i
  11.     count=$(($count+1))
  12.   else
  13.     pdftotext "$i" - | grep --color=always -i "$term" | sed -e "s/^/$i: /"
  14.     count=$(($count+1))
  15.   fi
  16. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement