pdfgrep.sh
#!/bin/bash # a slightly modified version of the original pdfgrep # which was made by Ulf Rompe <ulf@@@@rompe.org> # http://blog.rompe.org/pdfgrep if [ $# -lt 2 ]; then echo 'Syntax: pdfgrep [grep options] <pattern> <file> [file ...]' exit 1 fi grepopts="" while [ `echo $1 | cut -c1` == "-" ]; do grepopts="$grepopts $1" shift done pat=$1 shift if [ $# -gt 1 ]; then shownames=1; else shownames=0; fi while [ $# -gt 0 ]; do output=`pdftotext -layout "$1" - | egrep --color=always $grepopts "$pat" | sed 's/\s\{2,\}//g'` if [ -n "$output" ]; then [ "$shownames" == 1 ] && echo -ne "\033[01;34m$1\033[00m: " echo $output fi shift done
qh/sh.txt · Last modified: 2009/11/03 11:05 by demod

