文章出處

  在正則表達式模式中,你也可以反轉自讀組的作用,你可以尋找組中沒有的任意字符,而不是去尋找組中含有的字符。要這么做的話,只要在字符組的開頭加個脫字符:

例如,data6的內容如下:

This is a test line
This is a different line.
This is a test of line
The cat is sleeping
That is a very nice hat.
at ten o'clock we'll go home
This test is at line two
hhi data6's content

匹配開頭不是T開頭的的

sed -n '/[^Ts]hi/p' data6

這時,所有帶有hi并且開始的字符串為T和s的都濾除了。

輸出:

hhi data6's content

注意,因為^也代表在首字母匹配,當把^符號移出[]內時,匹配的就是在開頭是T和s開頭并帶有hi的字符了

sed -n '/^[Ts]hi/p' data6

輸出:

This is a test line
This is a different line.
This is a test of line
This test is at line two

 


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()