fetch specific string from another string

Discussion in 'Programming/Scripts' started by Poliman, Mar 30, 2018.

  1. Poliman

    Poliman Member

    I have command:
    Code:
    x=`grep Relay /var/log/mail.log | sed 's/s1 amavis.*},//;s/\(Queue-ID\|Message-ID\).*, Hits/Hits/;s/Hits:\([^,]\+\).*/Hits:\1/' | grep --color=always '<[^@<>]*@[^@<>]*\.[^@<>]*>'`
    echo $x
    
    which produces information like below - "Hits" value are amavis spam score:
    Code:
    Mar 26 14:35:33 LOCAL [127.0.0.1] <[email protected]> -> <[email protected]>, Hits: -3.812
    Mar 26 14:39:05 ORIGINATING LOCAL [::1]:47724 <[email protected]> -> <[email protected]>, Hits: 0.179
    
    I would like to get each of "Hits: " value to variable. I need to evaluate each of this value to know that is or not mail which could be a spam. After this I want send an email that specific email could be spam.
     

Share This Page