Linux – Delete All Files Matching Pattern In Directory

greplinux

How can I delete all files containing -20 in the filename in the current directory?

I have

ls | grep "-20" | rm -rf

But that does not work. Ideas?

Thanks.

Best Answer

rm -- *-20*

The -- stops -20 being treated as an argument to rm if the file -20 exists.