shell数组的使用
Bshell
#!/bin/bash #set -x IFS="|" str=`A|B|C` array=($str) length=${#array[@]} echo $length for (( i=0; i<$length; i++ )) do echo ${array[$i]} done
Kshell
#!/bin/ksh #set -x IFS="|" str=`A|B|C` set -A array ${str} length=${#array[@]} echo $length echo "++" echo ${array[0]} echo ${array[1]} echo ${array[2]} echo "++" for i in ${array[*]} do echo $i done