Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-23-2007, 10:14 AM   #1
LQ Newbie
Registered: Jun 2007
Posts: 7

Rep: Reputation: 0
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:
java Grid1 < slab.gro > slab1.gro
Then the next program I would run is:
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:
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!
Old 06-23-2007, 10:57 AM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
for i in $(seq 1 288)
  java Grid2 < slab.gro > slab${i}.gro
  genconf -f slab${i}.gro -o slab${i}.pdb
sh ./
Old 06-23-2007, 02:42 PM   #3
LQ Newbie
Registered: Jun 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Oh, perfect! Thank you so much!
Old 06-23-2007, 09:08 PM   #4
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Give a man a fish.........

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


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
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
about shell scripting qrshat Programming 3 04-20-2006 10:22 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 04:32 PM
shell scripting emailssent Programming 4 03-16-2005 11:39 PM > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration