精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學(xué)習(xí)啦>學(xué)習(xí)電腦>操作系統(tǒng)>Linux教程>

      linux中的grep命令的用法詳解(2)

      時(shí)間: 佳洲1085 分享

        查找非小寫(xiě)字母加oo的內(nèi)容

        [root@ www.linuxidc.com]# grep -n '[^a-z]oo' regular_express.txt

        3:Football game is not use feet only.

        獲取有數(shù)字的一行

        [root@ www.linuxidc.com]# grep -n '[0-9]' regular_express.txt

        5:However, this dress is about $ 3183 dollars.

        15:You are the best is mean you are the no. 1.

        [root@ www.linuxidc.com]# grep -n '[^[:lower:]]oo' regular_express.txt

        3:Football game is not use feet only.

        查詢以the開(kāi)頭的字符

        [root@ www.linuxidc.com]# grep -n '^the' regular_express.txt

        12:the symbol '*' is represented as start.

        查詢開(kāi)頭是小寫(xiě)字母的內(nèi)容

        [root@ www.linuxidc.com]# grep -n '^[a-z]' regular_express.txt

        2:apple is my favorite food.

        4:this dress doesn't fit me.

        10:motorcycle is cheap than car.

        12:the symbol '*' is represented as start.

        18:google is the best tools for search keyword.

        19:goooooogle yes!

        20:go! go! Let's go.

        查詢第一個(gè)字符不是大寫(xiě)的

        [root@ www.linuxidc.com]# grep -n '^[[:lower:]]' regular_express.txt

        2:apple is my favorite food.

        4:this dress doesn't fit me.

        10:motorcycle is cheap than car.

        12:the symbol '*' is represented as start.

        18:google is the best tools for search keyword.

        19:goooooogle yes!

        20:go! go! Let's go.

        查詢不是以英文開(kāi)頭的字符

        [root@ www.linuxidc.com]# grep -n '^[^a-zA-Z]' regular_express.txt

        1:"Open Source" is a good mechanism to develop programs.

        21:# I am VBird

        查詢結(jié)尾是小數(shù)點(diǎn)的行的內(nèi)容.

        [root@ www.linuxidc.com]# grep -n '\.$' regular_express.txt

        1:"Open Source" is a good mechanism to develop programs.

        2:apple is my favorite food.

        3:Football game is not use feet only.

        4:this dress doesn't fit me.

        10:motorcycle is cheap than car.

        11:This window is clear.

        12:the symbol '*' is represented as start.

        15:You are the best is mean you are the no. 1.

        16:The world <Happy> is the same with "glad".

        17:I like dog.

        18:google is the best tools for search keyword.

        20:go! go! Let's go.

        查找“空白行”

        [root@ www.linuxidc.com]# grep -n '^$' regular_express.txt

        22:

        通配符.和*的使用,.(小數(shù)點(diǎn))代表一定有一個(gè)任意字符,*代表重復(fù)前一個(gè)到無(wú)窮多次的意思

        [root@ www.linuxidc.com]# grep -n 'g..d' regular_express.txt

        1:"Open Source" is a good mechanism to develop programs.

        9:Oh! The soup taste good.

        16:The world <Happy> is the same with "glad".

        查詢出現(xiàn)任意數(shù)字的行列

        [root@ www.linuxidc.com]# grep -n '[0-9][0-9]*' regular_express.txt

        5:However, this dress is about $ 3183 dollars.

        15:You are the best is mean you are the no. 1.

        查詢出現(xiàn)兩個(gè)o的字符串

        [root@ www.linuxidc.com]# grep -n 'o\{2\}' regular_express.txt

        1:"Open Source" is a good mechanism to develop programs.

        2:apple is my favorite food.

        3:Football game is not use feet only.

        9:Oh! The soup taste good.

        18:google is the best tools for search keyword.

        19:goooooogle yes!

        查詢出現(xiàn)2-5個(gè)o的字符串,后面在接一個(gè)g的字符串

        [root@ www.linuxidc.com]# grep -n 'o\{2,5\}g' regular_express.txt

        18:google is the best tools for search keyword.

        19:goooooogle yes!

        查詢出現(xiàn)2個(gè)以上o的字符串,后面在接一個(gè)g的字符串

        [root@ www.linuxidc.com]# grep -n 'o\{2,\}g' regular_express.txt

        18:google is the best tools for search keyword.

        19:goooooogle yes!

        三、擴(kuò)展資料:linux中g(shù)rep命令之正則表達(dá)式

        匹配字符:這部分和基本正則表達(dá)式一樣

        匹配次數(shù):

        * :和基本正則表達(dá)式一樣

        ? :基本正則表達(dá)式是\?,二這里沒(méi)有\(zhòng)。

        {m,n} :相比基本正則表達(dá)式也是沒(méi)有了\。

        + :匹配其前面的字符至少一次,相當(dāng)于{1,}。

        位置錨定:和基本正則表達(dá)式一樣。

        分組及引用:

        (string) :相比基本正則表達(dá)式也是沒(méi)有了\。

         class="main">

      linux中的grep命令的用法詳解(2)

      時(shí)間: 佳洲1085 分享

        或者:

        a|b :匹配a或b,注意a是指 | 的左邊的整體,b也同理。比如 C|cat 表示的是 C或cat,而不是Cat或cat,如果要表示Cat或cat,則應(yīng)該寫(xiě)為 (C|c)at 。記住(string)除了用于引用還用于分組。

        常用正則表達(dá)式部分就說(shuō)到這里,以后用到在另行補(bǔ)充,如果你有興趣也可以去網(wǎng)上查找其他文章來(lái)進(jìn)一步了解。

      3635303