Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    6

    Unanswered: grep mutiple erpressions

    I want to use grep to ckeck file errors, in which case ,I used
    number_of_errors=$(grep -v -c (pattens) file)
    there r 2 problems , firstly , I want to use mutiple pattens and match any one of them (in this case if non of them is matched, since -v is used as an option).
    2ndly, I want to assign the returned number to a variable, and my expression is incorrect.....
    Any help would be appreciated.^_^
    thanks for ur attention.

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    use 'egrep' or 'grep -E' :

    Code:
    #Count lines with ERROR or WARNING
    count1=$(egrep -c 'ERROR|WARNING) file)
    
    #Count lines without ERROR and WARNING
    count2=$(egrep -v -c 'ERROR|WARNING' file)
    Jean-Pierre.

  3. #3
    Join Date
    Feb 2004
    Posts
    6
    It works ,many thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •