Open the way
Open the way

Reputation: 27329

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

Upvotes: 5

Views: 6719

Answers (2)

mikey
mikey

Reputation: 5160

rm -rf '*filter*' 

Should work well. Use quotes (updated to single based on comment).

Upvotes: 0

Paul Tomblin
Paul Tomblin

Reputation: 182772

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

Upvotes: 12

Related Questions