How to expand both a variable name and a wildcard in a file name


I have a bash script where $DIR is a directory name that may contain spaces.


rm "$DIR/*.MOV"

gives the error "No such file or directory". There is no file literally named "*.MOV"; I want the * to expand into multiple arguments – one per matching filename.


rm some\ folder/foo.MOV some\ folder/bar.MOV

How can I do this?

Best Answer

Quoting prevents globbing. Try this with GNU bash:

rm "$DIR"/*.MOV
Related Question