Is there a better way to run a command N times in bash?

If your range has a variable, use seq, like this:

count=10
for i in $(seq $count); do
    command
done

Simply:

for run in {1..10}; do
  command
done

Or as a one-liner, for those that want to copy and paste easily:

for run in {1..10}; do command; done

Leave a Comment