Reputation: 7875
Is there a way to suppress globbing in parameter expansion? Consider the case of a file named literally *.xml
in a directory among other xml files. Is there a way to do a parameter expansion ${param##*/}
affecting only the file *.xml
and not all the xml files?
param=./*.xml
echo "$param" # Displays only ./*.xml
echo $param # Displays ./*.xml ./invoice.xml ./bla.xml ...
echo ${param##*/} # Displays *.xml invoice.xml bla.xml ...
# what I want:
echo ${param##*/} # Displays only *.xml
Upvotes: 1
Views: 177
Reputation: 786011
Converting my comment to answer so that solution is easy to find for future visitors.
Problem is not quoting your BASH expressions that allows shell to expand globs or wildcards.
You should be using quotes in shell as:
param='./*.xml'
echo "$param"
echo "${param##*/}"
Upvotes: 2