且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用bash / aliases删除目录中grep文件的最有效方法

更新时间:2023-11-25 14:19:16

您没有提供任何示例输入/输出,因此未经测试,但这听起来像是您要尝试的操作:

You didn't provide any sample input/output so this is untested but it sounds like this is what you're trying to do:

my_new_del() {
    find /home/vmail -type f -name '*.some.file.pattern*' -exec grep -i -H -l -s "$1" {} + |
    xargs rm -f {}
}

我假设您的文件名称不包含任何空格,因为您现有的脚本依赖该假设。

I'm assuming your file names don't contain any white space since your existing script relies on that assumption.