How do I match everything except certain characters using grep?



  • Example textfile used.

    $ cat textfile
    If the boots fit
    boots
    bootss
    

    We want to match everything but not the characters bots. The characters in red are the matches. The characters b, o, t, and s are not matched, everything else is.

    $ grep -E "[^bots]" textfile
    If the boots fit
    bootsy was here
    

    6841f7d4-9565-44f2-9d26-845852086ffb-image.png


Log in to reply
 

© Lightnetics 2024