I'd like to have this modified to:
- 1) Open a shell.
2) Ask for a path
3) Ask for a pattern.
4) Results to stdout.
If easy enough and you have the time, I'd love a walk-through.
Thanks.
Code: Select all
#!/bin/bash
tail -n +5 "$0" > /tmp/pdfgrepcli # Copy itself, except first 4 lines, to /tmp/pdfgrepcli
exec xterm -hold -e bash /tmp/pdfgrepcli # open terminal and execute /tmp/pdfgrepcli
# -----------------------------------------------------------------------------
[ ! `which pdfgrep` ] && echo "Install 'pdfgrep' first, exiting..." && exit 1
read -p "Path: " PDFPATH
read -p "Pattern: " PATTERN
find "$PDFPATH" -type f -iname "*.pdf" -exec pdfgrep "$PATTERN" {} +
Code: Select all
pdftotext /usr/share/examples/ps-pdf/Acrobat.pdf - | grep --color=always "document"
Code: Select all
[ ! `which pdfgrep` ] && echo "Install 'pdfgrep' first, exiting..." && exit 1
read -p "Path: " PDFPATH
read -p "Pattern: " PATTERN
find "$PDFPATH" -type f -iname "*.pdf" -exec pdfgrep "$PATTERN" {} +
This is one of the first tricks I have learned.Is tail -n +5 "$0" > /tmp/pdfgrepcli setup as a buffer to store input while waiting for further instruction?
Code: Select all
-exec pdfgrep "$PATTERN" {} +