Interview Prep/Shell Scripting/Arrays, conditionals and loops

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
All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Arrays, conditionals and loops