-   Programming (
-   -   command application problem (

mkingiii 10-26-2006 02:55 PM

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:


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 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.

mkingiii 10-26-2006 03:07 PM

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.

mkingiii 10-26-2006 06:01 PM

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.

ntubski 10-26-2006 08:48 PM


for file in ./aa*/prod/*/*/final.pdf.gz; do
  gunzip $file --to-stdout | perl -p -e 's/YSN/LYS/g' |gzip > $file

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.

mkingiii 10-27-2006 12:24 AM

Thanks, I will run a few tests and see if that works.

All times are GMT -5. The time now is 12:57 AM.