I'm trying to create a shell script that runs through a bunch of SQL scripts.
I've these files:
$ ls upgrade/ 01-foo.sql 02-bar.sql 02-baz.sql 03-foo1.sql 04-buz.sql
And I've got the version of the current db, e.g.
How can I now easily loop through and glob the files with a prefix greater than my $DB_VERSION, and run them in order ?
i.e. I'd like to do
for f in ???? ; do mysql < $f done
and, with DB_VERSION=02, run the
04-buz.sql , in that order.