cat test.sh # 定义一个空的数组 array=() ping -w 1 192.168.1.1 > /dev/null 2>&1 array+=($?) ping -w 1 192.168.1.1 > /dev/null 2>&1 array+=($?) ping -w 1 127.0.0.1 > /dev/null 2>&1 array+=($?) echo ${array[*]} # sh test.sh 1 1 0
标签:元素,ping,dev,sh,添加,数组,array,null From: https://www.cnblogs.com/suyj/p/17043789.html