使用 grep -Pe 和正则表达式查找图像时避免 "Aborted (core dump)" 错误?

Avoid "Aborted (core dump)" error when using grep -Pe and regex to find images?

我正在编写一个 bash-脚本,它应该将图片的所有生成版本移动到另一个文件夹,即 original-image.jpg 不应移动,但 original-image-120x240.jpg 和 original-image-1920x1080.jpg 应该移动。

但是,我的脚本在执行此命令时失败:

find image-folder/ -type f | grep -Pe '-(\d{2,4})x(\d{2,4})\.(jpeg|jpg|png|gif)'

Aborted (core dumped)

我在这里做错了什么? "Aborted (core dumped)"的原因是什么?内存不足?

是否有其他方法可以帮助我避免此错误?

我在 CentOS 上 运行 这个。

假设目录中的所有文件属于原始文件或调整后的文件,您可以使用 find 本身找到调整后的图像。

find image-folder/ -type f -regex '.*-[1-9][0-9]*x[1-9][0-9]*\.(jpe?g|png|gif)'