Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In the shell script, I will have to access the binary logs stored in /usr/local/mysql/data. but when I do this,

STARTLOG=000002
ENDLOG=000222
file=`ls -d /usr/local/mysql/data/mysql-bin.{$STARTLOG..$ENDLOG}| sed 's/^.*\///'`
echo $file

I get the below error :

ls: cannot access /usr/local/mysql/data/mysql-bin.{000002..000222}: No such file or directory. 

But when I manually enter the numbers in the range the shell scripts runs normally without error.

share|improve this question

closed as off topic by mdpc, Michael Hampton, Ward, Khaled, Sven Feb 18 '13 at 8:50

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Which shell are you using in your console session? (i.e. echo $SHELL) in your script? (Usually the first line #!/xxx/xxx) –  mdpc Feb 18 '13 at 6:48

1 Answer 1

up vote 1 down vote accepted

Try using seq(1):

file=`ls -d $(seq --format="/usr/local/mysql/data/mysql-bin.%06.0f" $STARTLOG $ENDLOG) | sed 's/^.*\///'`
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.