sed: Can my pattern contain an “is not” character? How do I say “is not X”?

后端 未结 4 989
夕颜
夕颜 2020-12-24 12:03

How do I say \"is not\" a certain character in sed?

4条回答
  •  长情又很酷
    2020-12-24 12:56

    For those not satisfied with the selected answer as per johnny's comment.

    'su[^x]' will match 'sum' and 'sun' but not 'su'.

    You can tell sed to not match lines with x using the syntax below:

    sed '/x/! s/su//' file
    

    See kkeller's answer for another example.

提交回复
热议问题