Commande line tool to recherche phrases in large number of pdf fichiers
Commande line tool to recherche phrases in large number of pdf fichiers
J'utilise Opensuse 10.3 and like to know ligne de commande tools to search phrases in large number of pdf fichiers inside a répertoire. In Windows XP the Explorer search allows this but is too lent. Is there grep tips ici?
Re: Commande line tool to recherche phrases in large number of pdf fichiers
SEARCH_DIR="/some/dir/where/you/want/to/search/";
SEARCH_STRING="whatever-you-are-searching";
# extracting text from pdf
pdftotext "fichier.pdf" "fichier.txt"
# connecting avec grep
pdftotext "fichier.pdf" /dev/stdout |grep -H --label="fichier.pdf" -- "$SEARCH_STRING"
# si vous want grep to show seulement fichier list of matching pdf fichier, add --fichiers-avec-matches
pdftotext "fichier.pdf" /dev/stdout |grep -H --label="fichier.pdf" --fichiers-avec-matches -- "$SEARCH_STRING"
# find possible list of pdf to search from
find "$SEARCH_DIR" -tapez f -name '*.pdf' > list-of-pdf.txt
# tout joined by awk as duct tape, sent to bash for processing
# double quote is escaped as x22 inside awk.
find "$SEARCH_DIR" -tapez f -name '*.pdf' |awk -v SEARCH_STRING="$SEARCH_STRING" '{
print "pdftotext \x22"$0"\x22 /dev/stdout | grep -H --label=\x22"$0"\x22 -- \x22"SEARCH_STRING"\x22"
}' |bash
# Avec out bash. Further processus to match your need
find "$SEARCH_DIR" -tapez f -name '*.pdf' |awk -v SEARCH_STRING="$SEARCH_STRING" '
{
EXEC="pdftotext \x22"$0"\x22 /dev/stdout | grep -H --label=\x22"$0"\x22 -- \x22"SEARCH_STRING"\x22";
while(EXEC|getline ret){
print "For fichier ["$0"] we have match ["ret"]";
# do whatever you like.
};
close(EXEC);
}'
SEARCH_STRING="whatever-you-are-searching";
# extracting text from pdf
pdftotext "fichier.pdf" "fichier.txt"
# connecting avec grep
pdftotext "fichier.pdf" /dev/stdout |grep -H --label="fichier.pdf" -- "$SEARCH_STRING"
# si vous want grep to show seulement fichier list of matching pdf fichier, add --fichiers-avec-matches
pdftotext "fichier.pdf" /dev/stdout |grep -H --label="fichier.pdf" --fichiers-avec-matches -- "$SEARCH_STRING"
# find possible list of pdf to search from
find "$SEARCH_DIR" -tapez f -name '*.pdf' > list-of-pdf.txt
# tout joined by awk as duct tape, sent to bash for processing
# double quote is escaped as x22 inside awk.
find "$SEARCH_DIR" -tapez f -name '*.pdf' |awk -v SEARCH_STRING="$SEARCH_STRING" '{
print "pdftotext \x22"$0"\x22 /dev/stdout | grep -H --label=\x22"$0"\x22 -- \x22"SEARCH_STRING"\x22"
}' |bash
# Avec out bash. Further processus to match your need
find "$SEARCH_DIR" -tapez f -name '*.pdf' |awk -v SEARCH_STRING="$SEARCH_STRING" '
{
EXEC="pdftotext \x22"$0"\x22 /dev/stdout | grep -H --label=\x22"$0"\x22 -- \x22"SEARCH_STRING"\x22";
while(EXEC|getline ret){
print "For fichier ["$0"] we have match ["ret"]";
# do whatever you like.
};
close(EXEC);
}'