How to use mod operator in bash? How to use mod operator in bash? bash bash

How to use mod operator in bash?


Try the following:

 for i in {1..600}; do echo wget http://example.com/search/link$(($i % 5)); done

The $(( )) syntax does an arithmetic evaluation of the contents.


for i in {1..600}do    n=$(($i%5))    wget http://example.com/search/link$ndone


You must put your mathematical expressions inside $(( )).

One-liner:

for i in {1..600}; do wget http://example.com/search/link$(($i % 5)); done;

Multiple lines:

for i in {1..600}; do    wget http://example.com/search/link$(($i % 5))done