我試圖打印嵌套for循環的結果一次,但我得到了循環中各種組合的結果。如何打印嵌套for循環的結果一次
這裏是我的代碼
for run in 1 2
do
for value in 3000 5000 1000
do
for percent in 30 40 50
do
echo "${percent}percent of ${value}"
done
done
done
我獲得以下的輸出:
for run1:30percent of 3000
for run1:40percent of 3000
for run1:50percent of 3000
for run1:30percent of 5000
for run1:40percent of 5000
for run1:50percent of 5000
for run1:30percent of 1000
for run1:40percent of 1000
for run1:50percent of 1000
for run2:30percent of 3000
for run2:40percent of 3000
for run2:50percent of 3000
for run2:30percent of 5000
for run2:40percent of 5000
for run2:50percent of 5000
for run2:30percent of 1000
for run2:40percent of 1000
for run2:50percent of 1000
我想打印輸出
for run1:30percent of 3000
for run1:40percent of 5000
for run1:50percent of 1000
for run2:30percent of 3000
for run2:40percent of 5000
for run2:50percent of 1000