-3

How can I pause my loop after x loops for x seconds?

My loop reads a list of IP addresses line by line. After 50 loops it should pause x seconds till the loop continues.

user3022917
  • 579
  • 2
  • 8
  • 20

1 Answers1

0
while read IP
do
<command>

# Sleep
((c++)) && ((c==50)) && sleep 60

done < input_file.txt
user3022917
  • 579
  • 2
  • 8
  • 20
  • 1
    You can put the `&&` inside a single `((...))` statement. `(( c++ && c == 50))`. However, do you want to pause *again* after another 50 lines? You need to reset the value of `c` to 0. An explicit `if` statement is probably cleaner: `if (( c == 50)); then c=0; sleep 60; else ((c++)); fi`. – chepner Mar 07 '19 at 17:52
  • Yes, I want to pause again after another 50 lines. Thank you! – user3022917 Mar 07 '19 at 17:59