OR / AND in grep - Aix

This is a discussion on OR / AND in grep - Aix ; Hi, for my understanding (can't find it in man pages or in grep doc), can someone confirm that: this statement is an OR? grep '^[abc] | [xyz]$' file1 this statement is an AND? grep '^[abc]' file1 | grep '[xyz]$' I've ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: OR / AND in grep

  1. OR / AND in grep

    Hi,

    for my understanding (can't find it in man pages or in grep doc), can
    someone confirm that:

    this statement is an OR?
    grep '^[abc] | [xyz]$' file1

    this statement is an AND?
    grep '^[abc]' file1 | grep '[xyz]$'

    I've tried but I'm not sure about the results.

    Thanks

  2. Re: OR / AND in grep

    On 16 Jul, 11:00, Huub wrote:
    > Hi,
    >
    > for my understanding (can't find it in man pages or in grep doc), can
    > someone confirm that:
    >
    > this statement is an OR?
    > grep '^[abc] | [xyz]$' file1
    >
    > this statement is an AND?
    > grep '^[abc]' file1 | grep '[xyz]$'
    >
    > I've tried but I'm not sure about the results.
    >
    > Thanks


    The first statment is an or, as you are using the pipe character '|'
    and the second could be considered an 'and' as you are grep'ing on a
    grep.


  3. Re: OR / AND in grep

    On Jul 16, 6:00 am, Huub wrote:
    > Hi,
    >
    > for my understanding (can't find it in man pages or in grep doc), can
    > someone confirm that:
    >
    > this statement is an OR?
    > grep '^[abc] | [xyz]$' file1


    When I want to do an OR search I use extended grep (egrep or grep -E):
    egrep '(^[abc]|[xyz]$)' file1
    >
    > this statement is an AND?
    > grep '^[abc]' file1 | grep '[xyz]$'


    If you want it to be ;-)

    >
    > I've tried but I'm not sure about the results.
    >
    > Thanks




  4. Re: OR / AND in grep

    Thank you for your replies.

+ Reply to Thread