查找未以特定扩展名结尾的文件

Lim*_*eth 2 regex bash shell grep

我正在制作一个bash脚本; 如何找到不以特定扩展名结尾的文件?

#!/bin/bash
find . -type f -print | grep "\.\(?!psd\|xcf\).+$"
Run Code Online (Sandbox Code Playgroud)

谢谢.

anu*_*ava 5

您可以使用:

find . -regextype posix-egrep -type f ! -regex '.*\.(psd|xcf)$'
Run Code Online (Sandbox Code Playgroud)

或者没有正则表达式:

find . -type f -not \( -name '*.psd' -o -name '*.xcf' \)
Run Code Online (Sandbox Code Playgroud)