LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-26-2006, 02:55 PM   #1
mkingiii
LQ Newbie
 
Registered: Oct 2006
Posts: 4

Rep: Reputation: 0
command application problem


I have several files, each of which contain lists of files. What I need to do is replace text in each of the files in the lists. Each of the files in the lists have a similiar designation:

./aa#/prod/#/#/final.pdb

The command sequence I am trying to employ is as follows:

gunzip ./aa#/prod/#/#/final.pdb.gz ; perl -pi -
e 's/YSN/LYS/g' ./aa#/prod/#/#/final.pdb ; gzip ./aa#/prod/#/#/final.pdb

The way I am trying to do it right now is to go copy the orginal file(#.file) containing the list of files into three new files (#.unzip, #.rep, and #.zip). I then open each of the new files using emacs, and find and replace ./ and .pdb with the respective commands. This is a bit of a time consuming process. I would greatly appreciate help if there a way better way to implement the commands.
 
Old 10-26-2006, 03:07 PM   #2
mkingiii
LQ Newbie
 
Registered: Oct 2006
Posts: 4

Original Poster
Rep: Reputation: 0
I guess what I would want to know is if there is a way to create a generic program file containing the command sequence I need to employ with place holders for the specific files from the lists. Something like:

gunzip xxx.gz ; perl -pi -e 's/YSN/LYS/g' xxx ; zip xxx

Then tell this program file to run the commands on the contents of the files containing the lists.
 
Old 10-26-2006, 06:01 PM   #3
mkingiii
LQ Newbie
 
Registered: Oct 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Not to be rude, but no one has any ideas? I see that people have viewed my post. If this isnt the right place for my post or if what I want to do isnt even possible please tell me. I have spent all day on google trying to figure out a way to do it. I am a novice at linux, so please help.
 
Old 10-26-2006, 08:48 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,396

Rep: Reputation: 814Reputation: 814Reputation: 814Reputation: 814Reputation: 814Reputation: 814Reputation: 814
Code:
for file in ./aa*/prod/*/*/final.pdf.gz; do
   gunzip $file --to-stdout | perl -p -e 's/YSN/LYS/g' |gzip > $file
done
I'm not sure if this text substitution is going to do what you want, pdf files don't have the text you see in a pdf viewer endcoded as ascii...

Note that I told gunzip to send the file to standard out so that I wouldn't have to worry about the change in the filename.
 
Old 10-27-2006, 12:24 AM   #5
mkingiii
LQ Newbie
 
Registered: Oct 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks, I will run a few tests and see if that works.
 
  


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
How to switch an application from one desktop to another using command line demianxyz Linux - Software 2 10-15-2006 06:36 PM
Command to show each application/process memory usage and its total gn00kie Linux - Enterprise 2 09-21-2006 03:08 AM
Command line Application search TheAvenger Linux - Software 3 06-20-2006 10:12 AM
sick of yahoo and the such, command line email application? dr_zayus69 Linux - Software 7 08-31-2005 07:23 PM
Where do I Put the Command Application Startup bpellet314 Linux - Newbie 6 07-07-2005 10:30 AM


All times are GMT -5. The time now is 09:26 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration