2012-07-29 57 views

回答

5

初始化數組:

ARGS=("[email protected]")    # "[email protected]" gives the arguments passed to the script 
ARGS=(arg1 arg2 arg3) # or fill the array out yourself 

顯示的數組項:

for ARG in "${ARGS[@]}"; do 
    printf '%s\n' "$ARG" 
done 
+0

1。也可以使用類似C的循環遍歷索引:'for((i = 0; i <$ {#ARGS [@]}; i ++));做printf「%d \ t%s \ n」$ i「$ {ARGS [i]}」; done' – 2012-07-29 21:49:32