[HN Gopher] Bash retry function with exponential backoff ___________________________________________________________________ Bash retry function with exponential backoff Author : geocrasher Score : 13 points Date : 2022-12-28 15:07 UTC (1 days ago) (HTM) web link (gist.github.com) (TXT) w3m dump (gist.github.com) | sillysaurusx wrote: | I was today years old when I learned that bash can do simple | arithmetic with $(($i + 1)). Thanks! | mmh0000 wrote: | If you just want to add/subtract 1, in bash you can do just | '((i++))', i.e.: [mmh@x670]$ i=0 | [mmh@x670]$ ((i++)); echo $i 1 [mmh@x670]$ ((i++)); | echo $i 2 | | Beware that the above is very -bashy- and purists will rip your | head off for using it. | sillysaurusx wrote: | Whoa. No dollar signs at all? | | I'm at Lowes -- does ((i+1)) work? Or is it just for | incrementing / decrementing (which is still very useful!) | | EDIT: thinking this over, does this work for variable | substitution too? E.g. ((i)) being equivalent to $i. Not that | you'd necessarily want to... | mmh0000 wrote: | To add arbitrary numbers, you'd have to do an assignment, | like this: [mmh@x670]$ ((i=i+2)); echo $i | 6 [mmh@x670]$ ((i=i+2)); echo $i 8 | mmh0000 wrote: | Also, the wooledge wiki is an amazing resource for Bash/shell | scripting. To learn more magic see: | https://mywiki.wooledge.org/ArithmeticExpression ___________________________________________________________________ (page generated 2022-12-29 23:00 UTC)