#pids=(123 345 678)
pids=$(ps -ef | grep key_word | grep -v grep | grep -v $$ | grep -v `basename $0` | awk '{print $2}')
pid_array=($pids) #ESplit into a array by " "
echo "array is:${pid_array[@]}" #Print the whole array
echo "array length is:${#pid_array[*]}" #Print the length of the array
echo ${pid_array[1]} #Print the second element in the array
pid_array[1]=91011 #Change the second element in the array
echo ${pid_array[1]} #Print the second element in the array again
Shell操作数组
最新推荐文章于 2023-05-10 15:17:13 发布