LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-15-2016, 12:11 PM   #1
atjurhs
Member
 
Registered: Aug 2012
Posts: 168

Rep: Reputation: Disabled
is there a way to grep thru *.pdf


hey guys, I have a directory with 20+ pdf files and I need to find info within 1 or more of them. the info will contain a specific string, let's say aBcDeFg. I know

[code\] grep -isnr aBcDeFg *.pdf [code]

won't work. is there something that will grep thru a bunch of pdf files?

thanks!

tabby

Last edited by atjurhs; 01-15-2016 at 12:13 PM. Reason: trying to figure out how to mark "code"
 
Old 01-15-2016, 12:13 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,027

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
maybe strings can help ?
 
Old 01-15-2016, 01:11 PM   #3
Tonus
Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-current with grub2
Posts: 386
Blog Entries: 3

Rep: Reputation: 97
is there a way to grep thru *.pdf

Could it be ok to convert them first to text ?
 
Old 01-15-2016, 01:15 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,937

Rep: Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692
Quote:
Originally Posted by atjurhs View Post
hey guys, I have a directory with 20+ pdf files and I need to find info within 1 or more of them. the info will contain a specific string, let's say aBcDeFg. I know

[code\] grep -isnr aBcDeFg *.pdf [code]

won't work. is there something that will grep thru a bunch of pdf files?

thanks!

tabby
First, the CODE tags are [ CODE] to start, and [/ CODE] to stop. As far as your issue goes, try pdftotext, which will convert that PDF file into text...which you can then pump through grep for a string. A simple loop:
Code:
 for file in /pdf/path/*.pdf; do pdftotext "$file"; done
..will convert them all into text. Change the 'pdftotext' to be your grep:
Code:
 for file in /pdf/path/*.txt; do grep aBcDeFg "$file"; done
 
Old 01-15-2016, 01:50 PM   #5
atjurhs
Member
 
Registered: Aug 2012
Posts: 168

Original Poster
Rep: Reputation: Disabled
TBOne thanks for your help! i'll give it a try...

and thanks for the code tags, I always forget them, i'll put them on a sticky...

tabby
 
Old 01-15-2016, 02:12 PM   #6
atjurhs
Member
 
Registered: Aug 2012
Posts: 168

Original Poster
Rep: Reputation: Disabled
yep, that worked, took a little while to convert them, thanks

tabby
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Edit PDF files On Ubuntu Linux using Master PDF Editor LXer Syndicated Linux News 0 01-05-2015 07:03 PM
LXer: Edit PDF files On Ubuntu Linux using Master PDF Editor LXer Syndicated Linux News 0 01-05-2015 03:10 PM
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 03:07 PM
Grep: how to make it not match PDF and HTML files? stf92 Linux - Desktop 8 06-27-2012 02:29 AM


All times are GMT -5. The time now is 04:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration