How to use mod operator in bash?

后端 未结 4 745
悲哀的现实
悲哀的现实 2020-12-22 23:05

I\'m trying a line like this:

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

What I\'m trying to get as output is:

4条回答
  •  礼貌的吻别
    2020-12-22 23:40

    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
    

提交回复
热议问题