bash数组array[*]、array[@]、"array[*]"、"array[@]"

bash数组array[*]、array[@]、"array[*]"、"array[@]"

matrix=("hi" "hello world" "1 2 3")

for item in ${matrix[*]};do

echo ${item}

done

echo "========================================="

for item in ${matrix[@]};do

echo ${item}

done

echo "========================================="

for item in "${matrix[*]}";do

echo ${item}

done

echo "========================================="

for item in "${matrix[@]}";do

echo ${item}

done

#     result:


#     hi                                                                                                                                                                                               
#     hello                                                                                                                                                                                            
#     world                                                                                                                                                                                            
#     1                                                                                                                                                                                                
#     2                                                                                                                                                                                                
#     3                                                                                                                                                                                                
#     =========================================                                                                                                                                                        
#     hi                                                                                                                                                                                               
#     hello                                                                                                                                                                                            
#     world                                                                                                                                                                                            
#     1                                                                                                                                                                                                
#     2                                                                                                                                                                                                
#     3                                                                                                                                                                                                
#     =========================================                                                                                                                                                        
#     hi hello world 1 2 3                                                                                                                                                                             
#     =========================================                                                                                                                                                        
#     hi                                                                                                                                                                                               
#     hello world                                                                                                                                                                                      
#     1 2 3   

posted @ 2021-04-14 23:01  MOVIT  阅读(242)  评论(0编辑  收藏  举报