Please, don't take this the wrong way, but before someone answers and tells me I should use an array, I'm looking for the reason why the following code doesn't work, not 'how to do it correctly'. I've searched the internet for the reason for this.
Given in bash:
function fn1 {
file=$HOME/$1*.cfg
echo $file
}
touch $HOME/abc-def.cfg
fn1 abc
returns /home/user/abc*.cfg
Why doesn't the * expand to give /home/user/abc-def.cfg
?
A workaround:
file=$HOME/$(ls -1 $HOME|grep $1)
is not elegant.
Background: I know there will be only one file that begins 'abc', but the rest of the filename can vary, I don't care about that, just the initial identifier (abc in the case above).
Lastly, great forum, use it a lot, but this is the first time I didn't find an answer, so my first posting - be kind :-)