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.
你能帮我吗,但是我怎样才能通过迭代将我从数组中读取的每个元素放回另一个数组中?
就像在第一次迭代中我读到 11.11.11-1 并且我需要将它放入第一个索引中的另一个数组中
第二次迭代我读到 22.22.22-2 我需要把它放到第二个索引的另一个数组中
谢谢 !
假设我正确阅读了您的问题,测试用例将是:
declare -a readarray declare -a another readarray=(11.11.11-1,22.22.22-2,33.33.33-3,44.44.44-4) num=${#readarray[@]} for ((i=0; i < num; i++)) do another[$i]=${readarray[$i]} done echo "${another[@]}"
你没有说你使用的是哪个 shell,我假设bash.
bash