Any Bash pros here? I've been into a rabbit hole a bit, and can't find an answer. My question is about pattern matching (i.e. globs). Can they be combined dynamically? The only technique I am aware of is to have to type them all out manually when they should be used repeatedly. Because of Bash's order of operations on expansions/substitutions, I know that patterns can be saved in some situations:
easy_glob='prefix*'
hard_glob='pre" "fix*'
$easy_glob # works when expanded in an appropriate context
$hard_glob # doesn't work, expands to a literal 'pre" "fix*'
I'd like to be able to save a complex pattern for the middle of a filename, which could contain spaces, parentheses, quotes, etc. And that way, I can recombine it into new patterns later on, something analogous to:
for f in "${prefix_4}${complex_glob}${suffix_2}"
Is such a thing possible?