我有一个脚本,其中有一个运行特定次数的 for 循环,我想知道是否可以在我的脚本中实现 pv 命令来添加进度条。
这是我的代码:
for i in $(seq 1 10000000); do
echo "iteration ${i}"
#rest of for loop
done
日志:
iteration 1
iteration 2
iteration 3
iteration 4
iteration 5
iteration 6
iteration 7
iteration 8
iteration 9
iteration 10
*and so on
如果有人能帮助我,我将不胜感激
编辑:我稍微改变了代码:
for i in $(seq 1 10000000); do
echo "iteration ${i}" | pv -l
#rest of for loop
done
它给了我这个输出:
1
1.00 0:00:00 [15.2k/s] [ <=> ]
2
1.00 0:00:00 [14.7k/s] [ <=> ]
3
1.00 0:00:00 [15.6k/s] [ <=> ]
4
1.00 0:00:00 [15.0k/s] [ <=> ]
5
1.00 0:00:00 [15.0k/s] [ <=> ]
6
1.00 0:00:00 [11.5k/s] [ <=> ]
7
1.00 0:00:00 [5.54k/s] [ <=> ]
8
1.00 0:00:00 [14.7k/s] [ <=> ]
9
1.00 0:00:00 [13.2k/s] [ <=> ]
10
1.00 0:00:00 [13.4k/s] [ <=> ]