LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 11:11 AM   #1
atjurhs
Member
 
Registered: Aug 2012
Posts: 311

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 11:13 AM. Reason: trying to figure out how to mark "code"
 
Old 01-15-2016, 11:13 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
maybe strings can help ?
 
Old 01-15-2016, 12:11 PM   #3
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405
Blog Entries: 3

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

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

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
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, 12:50 PM   #5
atjurhs
Member
 
Registered: Aug 2012
Posts: 311

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, 01:12 PM   #6
atjurhs
Member
 
Registered: Aug 2012
Posts: 311

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

tabby
 
  


Reply



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 06:03 PM
LXer: Edit PDF files On Ubuntu Linux using Master PDF Editor LXer Syndicated Linux News 0 01-05-2015 02:10 PM
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 02:07 PM
Grep: how to make it not match PDF and HTML files? stf92 Linux - Desktop 8 06-27-2012 01:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:31 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
Open Source Consulting | Domain Registration