Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Very Simple Question!!

52 views
Skip to first unread message

deteva...@gmail.com

unread,
Sep 19, 2015, 3:17:25 AM9/19/15
to
Hallo

I am not familiar with the code to do shell scripting..... I only know windows codes

I want to write a simple for loop to submit a job 359 times so:

for i=0,359 do begin

exb dosxyznrc name_(i).egsinp etc

endfor

how do I write this so that the name name_(i) changes from name_0 to name_1 etc all the way to 359?

Thank you

Kenny McCormack

unread,
Sep 19, 2015, 5:09:14 AM9/19/15
to
In article <15dba7ae-e580-4643...@googlegroups.com>,
#!/bin/csh
set i=0
while ($i < 360)
exb dosxyznrc name_$i.egsinp
@ i++
end

Note that this will run the command 360 times, not 359 as you said above.

--
"I think I understand delicate, but why do I have to wash my hands, and
be standing in cold water when doing it?"

Kaz Kylheku <k...@kylheku.com> in comp.lang.c

Stephane Chazelas

unread,
Sep 19, 2015, 6:10:10 AM9/19/15
to
2015-09-19 00:17:19 -0700, deteva...@gmail.com:
> Hallo
>
> I am not familiar with the code to do shell scripting..... I only know windows codes
>
> I want to write a simple for loop to submit a job 359 times so:
>
> for i=0,359 do begin
>
> exb dosxyznrc name_(i).egsinp etc
[...]

With zsh:

i=0; repeat 360 exv dosxyznrc name_$((i++)).ghsinp etc

Or:

for ((i=0;i<360;i++)) exv dosxyznrc name_$((i++)).ghsinp etc

With all shells provided you have a seq command:

seq 0 359 | xargs -I% exb dosxyznrc name_%.egsinp etc

--
Stephane

deteva...@gmail.com

unread,
Sep 19, 2015, 9:37:17 AM9/19/15
to
Thank you

ex dosxyznrc is a command with its own script, will it still work?

This makes No sense to me lol

Janis Papanagnou

unread,
Sep 19, 2015, 10:33:49 AM9/19/15
to
And what shell do you want to use? - In modern shells (ksh, bash, ...) you
could use an arithmetic for-loop, the construct that probably matches best
(optically) with your code above...

for ((i=0; i<=359; i++))
do
exb dosxyznrc name_${i}.egsinp etc
done


> ex dosxyznrc is a command with its own script, will it still work?

If you can call that script stand-alone as you did you can also use it in
the for-loop; your command 'exb' needs execution permission for that.
Otherwise, if it's also a shell script use the respective shell to call it,
e.g. maybe one of

bash exb dosxyznrc name_${i}.egsinp etc

sh exb dosxyznrc name_${i}.egsinp etc

Note that the available shell languages differ. There's a widely available
shell language subset defined by a standard (POSIX), but modern systems
support more powerful or better readable constructs (like the loop above).

Janis

Janis Papanagnou

unread,
Sep 19, 2015, 10:35:29 AM9/19/15
to
On 19.09.2015 12:07, Stephane Chazelas wrote:
>
> for ((i=0;i<360;i++)) exv dosxyznrc name_$((i++)).ghsinp etc

I suppose that's one increment too much.

Janis

Barry Margolin

unread,
Sep 19, 2015, 5:07:49 PM9/19/15
to
In article <mtjrre$7o1$2...@news.m-online.net>,
Yeah. Either ++ in the for() or in the $(()), not both.

Another way in shells that have the range operator, like bash:

for i in {1..360}; do
exv dosxyznrc name_$i.ghsinp etc
done

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Message has been deleted

deteva...@gmail.com

unread,
Sep 20, 2015, 5:35:26 AM9/20/15
to
Can I maybe change my question

I want a script that ex dosxyznrc then opens a new terminal change the directory and ex dosxyznrc again

at the moment I have - please refrain from laughing at me I know Nothing about shell scripting :-)

ex dosxyznrc etc
gnome-terminal
cd egsnrc/dosxyznrc
ex dosxyznrc etc

it only does the first command

Pleeassee Help?

Barry Margolin

unread,
Sep 20, 2015, 4:21:36 PM9/20/15
to
In article <55e40b2d-e6d4-4301...@googlegroups.com>,
If you want to execute commands inside the terminal window, you have to
pass them using the -e argument. Your script is waiting for
gnome-terminal to complete before it executes the next command.

gnome-terminal -e "cd egsnrc/dos; ex dosxyznrc etc"

Kaz Kylheku

unread,
Sep 20, 2015, 11:10:06 PM9/20/15
to
On 2015-09-20, deteva...@gmail.com <deteva...@gmail.com> wrote:
> I want a script that ex dosxyznrc then it should open a new terminal cd the
> diretory and execute the command again and so on...

Please change your preferences so that you want something that isn't completely
stupid.
0 new messages