Regex lookahead for 'not followed by' in grep

前端 未结 5 2001
忘了有多久
忘了有多久 2020-11-27 13:31

I am attempting to grep for all instances of Ui\\. not followed by Line or even just the letter L

What is the proper way to wr

5条回答
  •  [愿得一人]
    2020-11-27 14:02

    The answer to part of your problem is here, and ack would behave the same way: Ack & negative lookahead giving errors

    You are using double-quotes for grep, which permits bash to "interpret ! as history expand command."

    You need to wrap your pattern in SINGLE-QUOTES: grep 'Ui\.(?!L)' *

    However, see @JonathanLeffler's answer to address the issues with negative lookaheads in standard grep!

提交回复
热议问题