spacer
spacer search

i-Vibe.com
developer resource & tips portal

Search
spacer
Newsflash
01/27/06: I just had some time to cleanup this website. I will add more articles for AJAX this coming weekend.
 
login.jpg
Main Menu
Home
Articles
Programming
Networking/Security
Data Modeling
Interface Design
Developer News
Downloads
Links
Login





Lost Password?
No account yet? Register
Related Articles
 
Home arrow Programming arrow Shell Scripts arrow Shell Script Iterate Through Array Values
Shell Script Iterate Through Array Values Print E-mail
  • Currently 3.3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Rating: 3.3/5 (4 votes cast)

Written by Roceller Alvarez   
Tuesday, 14 February 2006
The following script will loop through the array values and print them out, one per line. Additional statements can be placed within the loop body to take further action.
# names store in "names" array.
names=( Dave Chris John Rob )

# here's how you iterate
for name in ${names[@]}
do
   echo $name
   # additional actions
done

Real world example:
# List of jobs
JOBS=( bp_daily1.sh cpn_daily1.sh )

# execute all jobs
for JOB in ${JOBS[@]}
do
   nohup $SRCDIR/${JOB} ${PROCESS_DATE} > $LOGDIR/${JOB}.out &
done

Comments

Only registered users can write comments.
Please login or register.

Powered by AkoComment 2.0!

 
< Prev   Next >
spacer
 
spacer