I am writing a script which accepts two arguments:
#! /bin/bash
eval for i in {$1..$2}; do echo $i; done
I run it like:
$ ./myscript 0002 0010
syntax error near unexpected token `do'
Why is the error?
I though it might be because the looping should be grouped. But by replacing eval for i in {$1..$2}; do echo $i; done
with eval { for i in {$1..$2}; do echo $i; done; }
, the error remains.
Note:
I hope to perform parameter expansion before brace expansion by using eval
.
The desired output of my example is 0002 0003 0004 0005 0006 0007 0008 0009 0010
. (See Perform parameter expansion before brace expansion?)