Register
It is currently Wed Nov 26, 2014 2:17 pm

Very simple question for short script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sun Dec 13, 2009 4:05 am   

Joined: Sun Dec 13, 2009 3:58 am
Posts: 1
Hey everyone, I'm completely new to bash scripting, but I desperately need it for my work. I'm sure you can answer my question in one sentence. :)

What I want to do is the folloiwing:

I have about 100 files and I have to use a perl program on each of them
They are named
star1
star2
...
star99
star100

Each time I use the perl program on a file a new output is generated

star1 -> star1_c
star2 -> star2_c
...and so on

So my script looks like that:

Quote:
#!/bin/bash
i=1

while [ $i -le 100 ]
do
perl Perl_program.pl star(i) > star(i)_c
i=$(( $i + 1 ))
done


but instead of the (i) I want to insert the current value of the variable i. How can I do that?

thanks :)


Top
 Profile  
 PostPosted: Sun Dec 13, 2009 8:22 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 569
I'd use a C-style_for_loop
Code:
for (( i=1; i<=100; i++ ))
do perl Perl_program.pl star$i > star${i}_c
done


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP