我需要找到所有的图像文件从目录(gif, png, jpg, jpeg)。

find /path/to/ -name "*.jpg" > log

如何修改这个字符串,不仅找到。jpg文件?


当前回答

添加-regextype posix-extended选项只在我的情况下有效:

sudo find . -regextype posix-extended -regex ".*\.(css|js|jpg|jpeg|png|ico|ttf|woff|svg)" -exec chmod 0640 {} \;

其他回答

在Mac OS上使用

find -E packages  -regex ".*\.(jpg|gif|png|jpeg)"
find /path/to -regex ".*\.\(jpg\|gif\|png\|jpeg\)" > log
find /path/to/  \( -iname '*.gif' -o -iname '*.jpg' \) -print0

将工作。也许有更优雅的方式。

添加-regextype posix-extended选项只在我的情况下有效:

sudo find . -regextype posix-extended -regex ".*\.(css|js|jpg|jpeg|png|ico|ttf|woff|svg)" -exec chmod 0640 {} \;
find /path -type f \( -iname "*.jpg" -o -name "*.jpeg" -o -iname "*gif" \)