Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将 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