Search code examples
bashfilenamesdelete-file

bash delete files whose filename contain asterisks


How can one in bash delete files whose filename contain asterisks? I mean, using wildcards. If I do

rm -fr *filter*

I will delete all files in which the word "filter" appears in the filename, but what when the files do contain asterisk?

EDIT: Following your advice, I am not able to delete this

*filter*xyz*.data

Solution

  • rm -rf \*filter\* or rm -rf '*filter*'