Sample Header Ad - 728x90

how do i use pv in a script that has a seq for loop

0 votes
2 answers
139 views
I have a script that has a for loop in it that runs a specific amount of times, and I was wondering if it is possible to implement the pv command in my script to add a progress bar. Here is my code:
for i in $(seq 1 10000000); do
    echo "iteration ${i}"
    #rest of for loop
done
log:
iteration 1
iteration 2
iteration 3
iteration 4
iteration 5
iteration 6
iteration 7
iteration 8
iteration 9
iteration 10
*and so on
if anyone can help me with this, any help would be greatly appreciated edit: i changed the code a bit:
for i in $(seq 1 10000000); do
    echo "iteration ${i}" | pv -l
    #rest of for loop
done
and it gave me this output:
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] [                                                                                                                               ]
Asked by harry mckay (9 rep)
Apr 10, 2025, 01:14 PM
Last activity: Apr 10, 2025, 05:28 PM