使用regex排除具有特定起始字符bash的文件



"/home/shell/DELETE-ME-*"包含shell目录中以DELETE-ME开头的所有文件。

以同样的方式,希望排除所有以DELETE-ME开头的文件-尝试了^[DELETE-ME-]^[DELETE-ME-*],但没有成功。

如何使用grep -v:

printf "%sn" /home/shell/* | grep -v '/DELETE-ME-'

OR使用find:

find /home/shell  -maxdepth 1 -type f ! -name "DELETE-ME-*"

看起来像是extglob 的作业

shopt -s extglob
echo !(DELETE-ME-*) # change echo to your actual command...
shopt -u extglob

最新更新