我尝试使用此代码删除所有包含特定表达式的文件。
# ! /bin/ bash
for i in `ls `; do
if [ ! -d $i ] && ([$i = violence] || [$i = hatred] || [$i = war]); then
rm $i
fi
done
我遇到以下错误(此目录中有两个文件“ war”和“ hatred”):
[hatred: command not found
[hatred: command not found
[hatred: command not found
[war: command not found
[war: command not found
[war: command not found
您能指出我的问题吗?