delete files matching pattern
A string contains “a number followed by an x
followed by a number” if and only if it contains a digit followed by an x
followed by a digit, i.e. if it contains a substring matching the pattern [0-9]x[0-9]
. So you're looking to remove the files whose name matches the pattern *[0-9]x[0-9]*[0-9]x[0-9]*.jpg
.
find /path/to/directory -type f -name '*[0-9]x[0-9]*[0-9]x[0-9]*.jpg' -delete
If your find
doesn't have -delete
, call rm
to delete the files.
find /path/to/directory -type f -name '*[0-9]x[0-9]*[0-9]x[0-9]*.jpg' -exec rm {} +