-2

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.

1
  • 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, 2013 at 6:48

1 Answer 1

1

Try using seq(1):

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

Not the answer you're looking for? Browse other questions tagged .