• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            doing5552

            記錄每日點滴,不枉人生一世

              C++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
              73 Posts :: 0 Stories :: 94 Comments :: 0 Trackbacks

            公告

            常用鏈接

            留言簿(24)

            我參與的團隊

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 454873
            • 排名 - 48

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            c2008-04-02 09:12
            Grep : g (globally) search for a re (regular expression ) and p (print ) the results.

            1、參數(shù):
            -I :忽略大小寫
            -c :打印匹配的行數(shù)
            -l :從多個文件中查找包含匹配項
            -v :查找不包含匹配項的行
            -n:打印包含匹配項的行和行標

            2、RE(正則表達式)
            \ 忽略正則表達式中特殊字符的原有含義
            ^ 匹配正則表達式的開始行
            $ 匹配正則表達式的結(jié)束行
            \< 從匹配正則表達式的行開始
            \>; 到匹配正則表達式的行結(jié)束
            [ ] 單個字符;如[A] 即A符合要求
            [ - ] 范圍 ;如[A-Z]即A,B,C一直到Z都符合要求
            . 所有的單個字符
            * 所有字符,長度可以為0

            3、舉例
            # ps -ef | grep in.telnetd
            root 19955 181 0 13:43:53 ? 0:00 in.telnetd

            # more size.txt size文件的內(nèi)容
            b124230
            b034325
            a081016
            m7187998
            m7282064
            a022021
            a061048
            m9324822
            b103303
            a013386
            b044525
            m8987131
            B081016
            M45678
            B103303
            BADc2345

            # more size.txt | grep '[a-b]' 范圍 ;如[A-Z]即A,B,C一直到Z都符合要求
            b124230
            b034325
            a081016
            a022021
            a061048
            b103303
            a013386
            b044525
            # more size.txt | grep '[a-b]'*
            b124230
            b034325
            a081016
            m7187998
            m7282064
            a022021
            a061048
            m9324822
            b103303
            a013386
            b044525
            m8987131
            B081016
            M45678
            B103303
            BADc2345

            # more size.txt | grep '' 單個字符;如[A] 即A符合要求
            b124230
            b034325
            b103303
            b044525
            # more size.txt | grep '[bB]'
            b124230
            b034325
            b103303
            b044525
            B081016
            B103303
            BADc2345

            # grep 'root' /etc/group
            root::0:root
            bin::2:root,bin,daemon
            sys::3:root,bin,sys,adm
            adm::4:root,adm,daemon
            uucp::5:root,uucp
            mail::6:root
            tty::7:root,tty,adm
            lp::8:root,lp,adm
            nuucp::9:root,nuucp
            daemon::12:root,daemon

            # grep '^root' /etc/group 匹配正則表達式的開始行
            root::0:root


            # grep 'uucp' /etc/group
            uucp::5:root,uucp
            nuucp::9:root,nuucp

            # grep '\<uucp' /etc/group
            uucp::5:root,uucp


            # grep 'root$' /etc/group 匹配正則表達式的結(jié)束行
            root::0:root
            mail::6:root


            # more size.txt | grep -i 'b1..*3' -i :忽略大小寫

            b124230
            b103303
            B103303

            # more size.txt | grep -iv 'b1..*3' -v :查找不包含匹配項的行

            b034325
            a081016
            m7187998
            m7282064
            a022021
            a061048
            m9324822
            a013386
            b044525
            m8987131
            B081016
            M45678
            BADc2345

            # more size.txt | grep -in 'b1..*3'
            1:b124230
            9:b103303
            15:B103303

            # grep '$' /etc/init.d/nfs.server | wc -l
            128
            # grep '\$' /etc/init.d/nfs.server | wc –l 忽略正則表達式中特殊字符的原有含義

            15
            # grep '\$' /etc/init.d/nfs.server
            case "$1" in
            >;/tmp/sharetab.$$
            [ "x$fstype" != xnfs ] && \
            echo "$path\t$res\t$fstype\t$opts\t$desc" \
            >;>;/tmp/sharetab.$$
            /usr/bin/touch -r /etc/dfs/sharetab /tmp/sharetab.$$
            /usr/bin/mv -f /tmp/sharetab.$$ /etc/dfs/sharetab
            if [ -f /etc/dfs/dfstab ] && /usr/bin/egrep -v '^[ ]*(#|$)' \
            if [ $startnfsd -eq 0 -a -f /etc/rmmount.conf ] && \
            if [ $startnfsd -ne 0 ]; then
            elif [ ! -n "$_INIT_RUN_LEVEL" ]; then
            while [ $wtime -gt 0 ]; do
            wtime=`expr $wtime - 1`
            if [ $wtime -eq 0 ]; then
            echo "Usage: $0 { start | stop }"


            # more size.txt

            the test file
            their are files
            The end

            # grep 'the' size.txt
            the test file
            their are files

            # grep '\<the' size.txt
            the test file
            their are files

            # grep 'the\>;' size.txt
            the test file

            # grep '\<the\>;' size.txt
            the test file

            # grep '\<[Tt]he\>;' size.txt
            the test file
            The end

            posted on 2010-11-01 19:08 doing5552 閱讀(1293) 評論(0)  編輯 收藏 引用

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久久久亚洲AV成人网| 久久久婷婷五月亚洲97号色| 精品久久久久久99人妻| 欧美日韩成人精品久久久免费看| 亚洲精品国产第一综合99久久| 亚洲中文字幕无码久久2017| 久久97精品久久久久久久不卡| 国产精品久久久久久久久久免费| 久久久久99精品成人片三人毛片| 久久婷婷五月综合国产尤物app| 久久久久人妻一区精品色| 久久久久一级精品亚洲国产成人综合AV区 | 国产精品成人99久久久久91gav | 少妇高潮惨叫久久久久久| 国产精品综合久久第一页| 久久久噜噜噜www成人网| 亚洲精品99久久久久中文字幕| 久久婷婷五月综合色高清 | 亚洲色欲久久久综合网| 成人午夜精品久久久久久久小说| 亚洲伊人久久精品影院| 欧美激情精品久久久久久久| 国产精品青草久久久久婷婷| 久久久久se色偷偷亚洲精品av| 激情综合色综合久久综合| 国产精品美女久久久久久2018| 国内精品久久久久久久久电影网| 久久久久久亚洲精品无码| 久久亚洲国产欧洲精品一| 久久久久久久人妻无码中文字幕爆| 亚洲性久久久影院| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 国产精品99精品久久免费| 国产偷久久久精品专区| 中文字幕精品久久久久人妻| 国产亚洲美女精品久久久| 久久国产精品一区| 欧美伊人久久大香线蕉综合69 | 国产精品久久久久久久久鸭| 九九久久自然熟的香蕉图片| 韩国免费A级毛片久久|