I have variables where I store regular expressions and than I want to find files in local folder that match that regex
Basically, I have regex for filename and for its extensions which I want to concatenate and then use them in ereg to search for files
So, here is an example of how it looks like:
declare -r CPMOVE_REGEX="^cpmove-[a-z][a-z0-9]{0,16}"
declare -r TAR_REGEX=".tar$"
and then somewhere in the scriptI do the following.
for b in $(ls -1 | egrep "$CPMOVE_REGEX$TAR_REGEX");
do
backups+=($b);
done
let's assume backups variable is declared somewhere before.
I understand that
$CPMOVE_REGEX$TAR_REGEX
is wrong, and I would like to know how to do it a right way.