Searching for and deleting files with a certain extension or ending with a number
remove the files ending with extension as well as any file ending with a number regardless of the extension
That requires conditions joined by logical OR instead of the default logical AND (parentheses are required because OR has lower precedence than AND, and they must be escaped or quoted so that the shell passes them to find
as literals):
find path/to/directory/ -type f \( -name '*.ext' -o -name '*[0-9].*' \) -print
Change -print
to -delete
once you are certain that it's doing the right thing. In the GNU implementation of find
, you may use -or
in place of -o
if you prefer.