Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Shell script to run x times

rajeshkumar created the topic: shell script to run x times
Problem:

First i need to cd to this directory $SWDIR/util
Second i need to run the following either 4 times or 20 times

./swadm add_process 1 BG Y

how can i put this in a script

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: Re:shell script to run x times
Solution

# Change directory
cd $SWDIR/util

# Set the variable n, which should store the number of iterations,
# either to 4 when condition "bla_bla" or else to 20
if bla_bla then
n=4
else
n=20
fi

# loop n times and do something in that loop
# (initialize the variable i with 1, then loop as long as i is
# smaller than or equal the variable n. increase i by 1 on
# every looping)
for (( i=1; i<=$n; i++ )) do ./swadm add_process 1 BG Y done

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x