【发布时间】:2020-09-02 10:59:52
【问题描述】:
我在该父目录中有一个名为 Stem 的父目录我有大约 20 个子目录和 20 个子目录名称以 _a 结尾,每个子目录有一个名为 violations.txt 的文件。在这 20 个子目录中,有两个子目录名为 Trans_a 和 shift_a,我不需要对这两个子目录执行任何脚本操作。 我只需要在 18 个子目录上执行我的脚本。
我尝试了下面的代码,但没有得到确切的输出。
#!/bin/bash
echo "These warning reports are based on this run directory:" ; pwd
echo " " ;
File="violatons.txt"
for d in *_a;
do
if ( "$d"=="Trans_a"||"shift_a" ); then
True
else
Statement
fi
done
注意:在某些情况下,我们需要在脚本中排除的子目录可能会增加或减少,这取决于情况。
【问题讨论】:
-
if条件可能是错误的。试试这个:unix.stackexchange.com/questions/47584/… -
@Kavitha :将您的脚本粘贴到shellcheck。你的
if也没有意义。if ( foo )在子 shell 中运行命令foo。
标签: bash shell for-loop pattern-matching