I am trying to pass a variable as part of an argument to a command. Specifically, I want mysqldump
to return elements whose ID is above some number. For example, this line works and returns all elements with ID above 30: mysqldump --user=MYUSER -p -B DB --tables sometable --where='id>30'
.
I have a script that determines this number and assigns it to variable LASTID. I would like to pass the value of this variable into the argument (in place of "30"). I run this:
mysqldump --user=MYUSER -p -B DB --tables sometable --where='id>"${LASTID}"'
But it returns the entire database, instead of using the correct id. It is as if it is ignoring what I am passing to LASTID.
I also tried this:
eval $(mysqldump --user=MYUSER -p -B DB --tables sometable --where='id>"${LASTID}"')
and eval echo $(mysqldump --user=MYUSER -p -B DB --tables sometable --where='id>"${LASTID}"')
.