LinuxQuestions.org
Visit Jeremy's Blog.
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 07-29-2011, 08:55 AM   #1
ciden
Member
 
Registered: Dec 2006
Location: New Delhi, India
Distribution: PCLinuxOS 2010
Posts: 246
Blog Entries: 1

Rep: Reputation: 31
apply a command to all pdf files in a directory


i want to apply this command

Code:
pdftotext article.pdf - | grep DOI
to all the pdf's in a directory and save each line of output to a text file.
i.e. i want to collect each line containing "DOI" from every pdf in a text file.

I am unable to understand bash scripting enough to write a for loop for this.
Some help will be highly appreciated.
 
Old 07-29-2011, 09:08 AM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,608

Rep: Reputation: 448Reputation: 448Reputation: 448Reputation: 448Reputation: 448
Quote:
Originally Posted by ciden View Post
i want to apply this command

Code:
pdftotext article.pdf - | grep DOI
to all the pdf's in a directory and save each line of output to a text file.
i.e. i want to collect each line containing "DOI" from every pdf in a text file.

I am unable to understand bash scripting enough to write a for loop for this.
Some help will be highly appreciated.
Hi,

will this do [UNTESTED]?
Code:
for FILE in /path/to/directory/*.pdf; do
  pdftotext "${FILE}" - | grep DOI >> DOI.results
done
 
  


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
Find directory older than x and mv directory with sub files command ajhart Linux - Newbie 4 07-15-2011 06:24 AM
converting .html files to pdf from the command line jason7 Linux - General 6 01-24-2009 09:46 AM
hoe to view pdf files in command mode. bruse Linux - Newbie 7 09-15-2005 11:03 AM
Apply permissions to all files in a directory leonard.sokol Linux - General 4 07-02-2005 09:09 PM
How can I read pdf files at the command line? hansi umayangan Linux - General 8 09-02-2004 08:27 AM


All times are GMT -5. The time now is 08:15 AM.

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