How do I group together multiple regular expressions using grep?



  • ( regex | regex | regex ) Is used to group together regular expressions.

    Example text file used.

    $ cat textfile
    The big bounty
    Big news is here
    The big shake-up
    

    We want to match different words after the word big.

    $ grep -E "\<big (bounty|shake-up)" textfile
    The big bounty
    The big shake-up
    

    5084a09f-a77d-433a-a93c-3c1b5a5da5ea-image.png


Log in to reply
 

© Lightnetics 2024