title: How to expand an argument with a range in square brackets in a bash script?
body: <p>I want to use strings containing numbers as input to my script. This list can be rather long and may contain consecutive ranges of numbers, so I thought about doing <code>ls</code> style list specification. However, how can I expand this list in my script?
  To be more specific, I want to run:</p>
  
  <pre><code>myscript node-[2,5-7,10-13]
  </code></pre>
  
  <p>and be able to loop through node-2, node-5, node-6, etc. in my script.</p>
  
  <p>Update: It seems that I need to use curly brackets and dots for lists. I can convert the string to that, but how do I make the script treat it as a list then? What I can do:</p>
  
  <pre><code>nodelist=`echo $1 | sed 's/\[/\{/' | sed 's/\]/\}/' | sed 's/-/../'`
  </code></pre>
  
  <p>but for input <code>node[1-3]</code> for example I get:</p>
  
  <pre><code>&gt;echo $nodelist
  node{1..3}
  </code></pre>