Bash wildcard expansion (2)

M Fero asked:

I’m sorry if this is too simple or has been covered before… but I hope someone here can help out. I can’t figure out how to expand the * wildcard in a pathname unless it is followed by a space. For example,

echo $path* $dir

yields

/Data0001 /subfolder 

which is what I want, but without the space. If I try to take out the space with,

echo $path*$dir

I get,

/Data*/subfolder

Any tips on how to get the * to expand without the whitespace?

Thanks.

My answer:


Put the variable name(s) in curly braces, e.g.:

echo ${path}*${dir}

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.