linux shell 数组装立及使用技巧

linux shell 数组建立及使用技巧

?

linux shell在编程方面比windows 批处理强大太多,无论是在循环、运算。已经数据类型方面都是不能比较的。 下面是个人在使用时候,对它在数组方面一些操作进行的总结。

?

1.数组定义

?

[chengmo@centos5 ~]$ a=(1 2 3 4 5)
[chengmo@centos5 ~]$ echo $a
1

?

一对括号表示是数组,数组元素用“空格”符号分割开。

?

2.数组读取与赋值

  • 得到长度

[chengmo@centos5 ~]$ echo ${#a[@]}
5

用${#数组名[@或*]} 可以得到数组长度

  • 读取

<blockquote style="background-image: none; background-color: #f0f0f0; border-top-width: 1px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 1px; border-top-style: dotted; border-right-style: solid; border-bottom-style: solid; border-left-style: dotted; border-top-color: black; border-right-color: black; border-bottom-color: black; border-left-color: black; color: black; margin-left: 0.5in; padding-left: 0.5em; padding-right: 0.5em; padding-top: 0.5em;

linux shell 数组装立及使用技巧

相关文章:

你感兴趣的文章:

标签云: