Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Programming in Linux _ automation help request

Posted by: mkingiii Oct 27 2006, 12:35 AM

Is there a way to run a sequence of commands on a list/number of files without having to run them manually on each file. I want to unzip each file, perform a find and replace on each file, and then rezip each file. The command sequence I want to employ is:

gunzip file.gz ; perl -pi -e 's/YSN/LYS/g' file ; gzip file

Each file I want to do this to has a similiar name as follows:

./aa#/prod/#/#/final.pdb.gz (for example: ./aa1/prod/50/0/final.pdb.gz)

Thanks.

Posted by: mkingiii Oct 27 2006, 02:13 PM

Ok, I know what I want to do can be done using a script file. However, I dont know how to write one. Can someone please help, this doesnt seem like that difficult a request for someone who knows what they are doing. Please help. I have 400000 files to run the commands on, so I really can not do this manually. I really need help to be able to apply the commands on a large scale.

Posted by: markjr Oct 27 2006, 04:12 PM

QUOTE (mkingiii @ Oct 27 2006, 03:13 PM) *
Ok, I know what I want to do can be done using a script file. However, I dont know how to write one. Can someone please help, this doesnt seem like that difficult a request for someone who knows what they are doing. Please help. I have 400000 files to run the commands on, so I really can not do this manually. I really need help to be able to apply the commands on a large scale.


You can use things like the "for" loop in bash, or xargs (man xargs)

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)