删除绝对路径中包含部署文件但不包含名称 DEV 的所有文件夹

删除绝对路径中包含部署文件但不包含名称 DEV 的所有文件夹

我想要一个通用/posix/ansible 解决方案来满足非 Windows(最好是 Solaris 和 Linux)的以下要求

-> 我希望列出所有文件/web/bea_apps/dev/TomcatNode01/deploy -> 然后删除deployfiles满足以下条件的所有文件夹:

条件1:找到的文件的文件路径应包含deployfiles

条件 2:文件路径不应包含不区分大小写的内容dev(将来自变量)

以下尝试没有帮助:

注意:在我的尝试中,我对环境进行了硬编码DEV,但它将是一个 ansible 或 shell 脚本变量。

find /web/bea_apps/dev/TomcatNode01/deploy \( -type d -name '*deployfiles*' -a ! -type d -name '*DEV*' \) -print
find /web/bea_apps/dev/TomcatNode01/deploy -type d -iname '*deployfiles*' ! -iname '*DEV*' -print
find /web/bea_apps/dev/TomcatNode01/deploy \( -type d -name '*deployfiles*' -o ! -type d -name '*DEV*' \) -print

输出:

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/qa/deployfiles

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/dev/deployfiles

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/uat/deployfiles

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/prod/deployfiles

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/perf/deployfiles

预期输出:

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/qa/deployfiles
  
/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/uat/deployfiles

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/prod/deployfiles

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/perf/deployfiles

因此;如果QA通过,以下将是预期的输出:

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/dev/deployfiles

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/uat/deployfiles

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/prod/deployfiles

/web/bea_apps/dev/TomcatNode01/deploy/conf/src/config/perf/deployfiles

操作系统版本:

uname -a

SunOS usdfw33as77v 5.11 11.4.62.151.3 sun4v sparc sun4v non-global-zone

请建议。

相关内容