如何将 bash 脚本中的所有参数保存到数组中并单独打印?
最佳答案
初始化数组:
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
关于Bash:保存并打印数组中的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11711461/