[root@bogon 20150109]# cat arr01.sh
array=(
caimz
leco
icpc
zhuminjie
huzhipeng
lirunqing
chenle
chenhongzhi
jianglei
)
echo ---------------------
for((i=0;i<${#array[@]};i++))
do
echo "This is num$i,then content is ${array[$i]}"
done
echo "The array Length is: ${#array[@]}"
echo ---------------------
执行结果
[root@bogon 20150109]# sh arr01.sh
---------------------
This is num0,then content is caimz
This is num1,then content is leco
This is num2,then content is icpc
This is num3,then content is zhuminjie
This is num4,then content is huzhipeng
This is num5,then content is lirunqing
This is num6,then content is chenle
This is num7,then content is chenhongzhi
This is num8,then content is jianglei
The array Length is: 9
---------------------
2、打印当前路径文件名
array=(
caimz
leco
icpc
zhuminjie
huzhipeng
lirunqing
chenle
chenhongzhi
jianglei
)
echo ---------------------
for((i=0;i<${#array[@]};i++))
do
echo "This is num$i,then content is ${array[$i]}"
done
echo "The array Length is: ${#array[@]}"
echo ---------------------
执行结果
[root@bogon 20150109]# sh arr01.sh
---------------------
This is num0,then content is caimz
This is num1,then content is leco
This is num2,then content is icpc
This is num3,then content is zhuminjie
This is num4,then content is huzhipeng
This is num5,then content is lirunqing
This is num6,then content is chenle
This is num7,then content is chenhongzhi
This is num8,then content is jianglei
The array Length is: 9
---------------------
2、打印当前路径文件名
编辑回复