shellScript之数组操作6

来源:互联网 发布:excel数据透视表作用 编辑:程序博客网 时间:2024/06/07 20:02
#!/bin/bashdeclare -a arrivedecho "what city have you been arrived?"echo "The input should be sperated from echo other by a space."read -a arrivedechofor i in "${arrived[@]}"do    echo $idoneecho "The length of this array is ${#arrived[@]}"echo "Executing UNSET operating..."unset arrived[1]echo "The length of this array is ${#arrived[@]}"echo "Executing  unset operating...."unset arrivedecho "The length of this array is ${#arrived[@]}"


结果:

~/script/shell_text $ ./11array.sh what city have you been arrived?The input should be sperated from echo other by a space.beijing handan tianjing shanghai hongkongbeijinghandantianjingshanghaihongkongThe length of this array is 5Executing UNSET operating...The length of this array is 4Executing  unset operating....The length of this array is 0