linux - 排除日志中的 grep 文件名

标签 linux bash for-loop grep

我的 bash 脚本有问题。我想从处理中排除 except.log 中列出的文件。文件处理完毕后,将被写入排除日志中。

for I in `ls $1 | grep ./exclude.log -v`

do
    echo "Procesing ...."
    echo $I >> ./exclude.log
done

最佳答案

$I 未赋值。 另外,您的 grep 格式不正确。

你可能想要

LIST=$( grep -v -f /path/to/exclude.log * )
for I in $LIST
do
        echo "Procesing ...."
        echo $I >> /path/to/exclude.log
done

确保排除.log 中没有任何空行

关于linux - 排除日志中的 grep 文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20126037/

相关文章:

bash - 在 bash 脚本中期待 × 16172

bash - 获取 n 个最后记录并更改它们的特定列

java - 是否每次都在for循环的condition语句中执行函数?

linux - SED 删除带有扩展名的单词

c++ - 用cmake叮当响。 target_include_directories “No such file or directory”

linux - 如何输出shell脚本的开始和停止日期时间(但不输出其他日志)?

c - 使用for循环计算c中的字长时出现意外结果

c++ - 在 for 循环中初始化迭代计数器是否效率较低?

c - 检测何时在 C 中连接了 USB 设备

linux - 如何随着时间的推移监控进程的内存使用情况 - ubuntu