|
Shell Script Iterate Through Array Values |
|
|
|
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
Only registered users can write comments. Please login or register. Powered by AkoComment 2.0! |