arcee123 arcee123 - 3 months ago 10
Linux Question

how do I remove files when the filename has specific characters from linux folder

I have a folder of images.

the folder looks like below:

dir/
--image1.png
--image1_600x600.png
--image1_1200x1200.png
--image2.png
--image2_600x600.png


How do I delete all files that have the 'x' character leaving only the original ones?

thanks

Answer

You can use find:

find dir -name '*x*' -delete