星期日, 7月 16, 2006

bash - for.sh

#!/bin/bash

COMMANDS=(
dmesg "cat /proc/asconf_info"
"cat /proc/cpuinfo"
)
#COMMANDS=(xxx yyy zz)

for i in ${COMMANDS}; do
    echo item:$i
done

echo "#="${#COMMANDS[*]}

i=0
while [ $i -lt ${#COMMANDS[*]} ]; do
    echo while:${COMMANDS[$i]}
    let i=i+1
done

echo ${COMMANDS[0]}
echo ${COMMANDS[1]}
echo ${COMMANDS[2]}

沒有留言: