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.
Try using seq(1)
:
file=`ls -d $(seq --format="/usr/local/mysql/data/mysql-bin.%06.0f" $STARTLOG $ENDLOG) | sed 's/^.*\///'`