0

For loop looks like

for i in {1..n}
do
...
done

Instead of fixed n I want to read it from arguments. How do I do it? I tried putting $1 instead of n but it didnt work.

anubhava
  • 761,203
  • 64
  • 569
  • 643
user27665
  • 673
  • 7
  • 27
  • 1
    Since you're using brace expansion, I assume you use Bash and don't require POSIX conformity? For the latter, see https://stackoverflow.com/questions/26529255/replacing-bash-arrays-and-c-style-for-loops-in-posix-sh – Benjamin W. Sep 14 '17 at 20:58
  • This is also [BashPitfalls #33](http://mywiki.wooledge.org/BashPitfalls#for_i_in_.7B1...24n.7D). – Charles Duffy Sep 14 '17 at 21:02

0 Answers0