LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shell Scripting (https://www.linuxquestions.org/questions/linux-newbie-8/shell-scripting-563948/)

nexisrocks 06-23-2007 09:14 AM

Shell Scripting
 
I have no idea how to write or run a shell script, however I would like to write one that would run 288 java programs sequentially (with each outputting to a different output file.

For example, were I just to run it in bash the command I would use is:
Code:

java Grid1 < slab.gro > slab1.gro
Then the next program I would run is:
Code:

java Grid2 < slab.gro > slab2.gro
The numbers in the filenames increase sequentially up to 288, and I would like to run a shell script that will, once written, run it all for me (so I do not have to run it myself 288 times). Would I just need one line and to change the numbers on each subsequent line in the script? If that is the case, what is the line I would need? I have no experience with shell scripting, so I am unsure as how it would work.

Also, how would I run the shell script once it is written?

After that is done, I would also like to run the command:
Code:

genconf -f slab1.gro -o slab1.pdb
This would also be run 288 times, with the numbers increasing up to 288. I would run it in another shell script, as it must be done on a different server.

Any help would be really, greatly appreciated!

acid_kewpie 06-23-2007 09:57 AM

script.sh:
Code:

for i in $(seq 1 288)
do
  java Grid2 < slab.gro > slab${i}.gro
  genconf -f slab${i}.gro -o slab${i}.pdb
done

Code:

sh ./script.sh

nexisrocks 06-23-2007 01:42 PM

Oh, perfect! Thank you so much!

pixellany 06-23-2007 08:08 PM

Give a man a fish.........

Bash Guide for Beginners---at tldp.org
Classic Shell Scripting---O'Reilly


All times are GMT -5. The time now is 05:31 PM.