简体   繁体   English

排除日志中的grep文件名

[英]grep filenames from an exclude log

I have a problem with my bash script. 我的bash脚本有问题。 I want to excluding from processing files that are listed in the exclude.log. 我想从exclude.log中列出的文件中排除。 After a file is processed it is written in to the exclude log. 处理文件后,将其写入排除日志。

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

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

You can use this while loop: 您可以使用以下while循环:

while read -r l; do
   echo "$l"; 
done < <(fgrep -v -wf exclude.log <(printf "%s\n" "$1"/*))

$I is not assigned a value. 没有为$ I赋值。 Also your grep is not right formulated. 另外,您的grep格式不正确。

You possibly want 你可能想要

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

Make sure you don't have any empty lines in exclude.log 确保exclude.log中没有任何空行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM