Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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 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
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.