What does `seq` do, and when should you use a C-style loop or brace expansion instead?
BeginnerConceptArrays, conditionals and loops
Answer
seq prints a number sequence: seq 1 5, seq -w 01 10 (zero-padded), seq 0 5 30 (step 5). It is an external command, so for pure Bash loops use for ((i=1; i<=n; i++)), which works with variables. Brace expansion {1..10} is fastest but only works with literal numbers.
for ((i = 1; i <= replicas; i++)); do echo "worker-$i"; done
More on Arrays, conditionals and loops
How do you declare, populate and iterate an indexed array?BeginnerWhat is the difference between `"${arr[@]}"` and `"${arr[*]}"`?IntermediateHow do associative arrays work and what are they good for in DevOps scripts?IntermediateHow do you read a command's output into an array correctly?IntermediateWhat is the difference between `[ ]`, `[[ ]]` and `(( ))`?BeginnerWhy does `[ $var = "prod" ]` fail when `var` is empty or contains spaces?Intermediate