1), the definition of the array (self-dividing):
Static array= (123)
Dynamic array array= ($ (command))
Example:
array= ($ (LS)) echo ${bb[@]} color01.sh color.sh ip.sh touch.sh tou.sh user.sh while01.sh while_02.sh
2), display the contents of the array
Echo ${array[@]}
Echo ${array[*]}
Show one of the character in the array, note that the first one is starting from 0 as follows:
Echo ${bb[3]}
3), build the scene using:
[email protected] 188]# cat check_weburl.sh #!/bin/sh./etc/init.d/functionsurl_list= (http://baidu.comhttp:// www.linuxpeixun.comhttp://51cto.comhttp://10.0.0.12http://www.baidu.com) for ((i=0;i<${#url_list [*]};i++)] Do Wget-t 4-q--spider ${url_list[$i]} >&/dev/null if [$?-eq 0];then action "${url_list[$i]}"/bin/true El Se action "${url_list[$i]}"/bin/false Fidoneecho "I am $USER Welcome to training class" |awk "{for (i=1;i<=nf;i++) if (length ($i) <=6) print $i} '
This article from "As always" blog, declined reprint!
Shell Array notes.