![删除绝对路径中包含部署文件但不包含名称 DEV 的所有文件夹](https://linux22.com/image/227010/%E5%88%A0%E9%99%A4%E7%BB%9D%E5%AF%B9%E8%B7%AF%E5%BE%84%E4%B8%AD%E5%8C%85%E5%90%AB%E9%83%A8%E7%BD%B2%E6%96%87%E4%BB%B6%E4%BD%86%E4%B8%8D%E5%8C%85%E5%90%AB%E5%90%8D%E7%A7%B0%20DEV%20%E7%9A%84%E6%89%80%E6%9C%89%E6%96%87%E4%BB%B6%E5%A4%B9.png)
我想要一个通用/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
请建议。