Bash Script

来源:互联网 发布:大学数据新闻作品 编辑:程序博客网 时间:2024/06/04 20:44

一:数组

     取最后一个元素:echo ${ARR1[${#ARR1[@]}-1]}  echo ${ARR1[@]:(-1)}echo "${array[-1]}"(Bash 4.2)

     To get both the index and the value:

for index in "${!array[@]}"do    echo "$index ${array[index]}"done

     移除元素: unset,

     shift: array=("${array[@]:1}")#removed the 1st element

0 0
原创粉丝点击