如何将bash脚本中的所有参数保存到数组并单独打印?
答案 0 :(得分:6)
初始化数组:
ARGS=("$@") # "$@" 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