Background:
I have a script which takes a filename as a parameter, for example "mydb.sql". My script imports this DB and "cleans" it (removes user identifiable data, etc), exports it and then creates a "lite" version (strips all non-essential data out, leaving only main admin user, removing all votes, etc). These get generated into mydb.clean.sql and mydb.lite.sql. This script gets run on several folders.
I want to create a wildcard pattern to pass into find. Originally I just hard coded '*.sql' which returned the original, clean and lite (these were then passed into du to give me a file size summary).
Now I have altered my script to take a parameter; the filename. This allows me to run it on a single file.
The Question
So how do I get the pattern? I have this:
FNAME=$(basename "$1");
FNAME="${FNAME%.*}*.sql"
echo $FNAME
This converts FNAME from /home/user/backups/sitea/mydb.sql to mydb. I then want FNAME to be the string 'mydb*.sql', however bash is expanding that * out so I end up with FNAME as 'mydb.sql mydb.clean.sql mydb.lite.sql' (assuming it found them in the CWD).
I have tries backslashing the *, however I then end up with 'mydb\*.sql' which doesn't work. I tried using single quotes, but then bash doesn't expand the ${FNAME%.*} part.
Any thoughts?
Update
This better illustrates the issue...
[user@server temp]$ T="${FNAME}\*.sql"; echo $T
mydb\*.sql
[user@server temp]$ T="${FNAME}*.sql"; echo $T
mydb.clean.sql mydb.lite.sql mydb.sql
[user@server temp]$ T='${FNAME}*.sql'; echo $T
${FNAME}*.sql