• <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>
            posts - 297,  comments - 15,  trackbacks - 0

            quote.txt

            The honeysuckle hand played all night long for only $90.

            It was an evening of splendid music and company.

            Too bad the disco floor fell through at 23:10.

            The local nurse Miss P.Neave was in attendance.

            顯示行

            $sed -n '2p' quote.txt

            范圍

            $sed -n '1,3p' quote.txt

            匹配單詞

            $sed -n '/The/'p quote.txt

            匹配某行單詞

            $sed -n '4,/The/'p quote.txt

            匹配元字符

            $sed -n '/\$/'p quote.txt

            顯示整個文件

            $sed -n '1,$p' quote.txt    sed -n '1,$'p quote.txt

            任意字符

            $sed -n '/.*ing/'p quote.txt  任意字符出現一次或N次 以ing結尾

            首末行

            $sed -n '1p' quote.txt

            $sed -n '$p' quote.txt

            打印行號

            $sed -n '/music/=' quote.txt

            2

            $sed -n -e '/music/p' -e '/music/=' quote.txt

            It was an evening of splendid music and company.

            2

            附加文件

            !/bin/sed -f

            /文件中匹配的字符/ a\

            插入的字符 +x; *.sed quote.txt

            刪除行

            $sed '1d' quote.txt 刪除第一行

            $sed '1,3d' quote.txt 刪除1到3行

            $sed '$d' quote.txt 刪除最后一行

            $sed '/Neave/d' quote.txt 刪除帶Neave的行

            替換文本

            $sed 's/night/NIGHT/' quote.txt  s替換/night/NIGHT/

            $sed 's/\$//' quote.txt  $換成空格

            $sed 's/The/Wow!/g' quote.txt    g替換所有

            $sed 's/splendid/SPLENDID/w sed.out' quote.txt  w sed.out此行寫入文件

            $sed -n 's/nurse/"Hello" &/p' quote.txt  

            The local "Hello" nurse Miss P.Neave was in attendance.

            $sed -n 's/played/from Hockering &/p' quote.txt

            將sed結果寫入文件命令

            $sed '1,2 w filedt' quote.txt 第一二行寫入文件

            $sed '/Neave/ w dht' quote.txt 匹配//的寫入文件

            從文件中讀文本

            $sed '/company./r sedex.txt' quote.txt

            在quote.txt的company后換行,寫入sedex.txt的內容

            匹配后退出

            $sed '/.a.*/q' quote.txt

            任意字符后跟a,再跟任意字符0次或任意次匹配:

            Line 1.band  Line 2.bad  Liner3.was  Line 4.was

            The honeysuckle hand played all night long for only $90.

            vi dos.txt

            12332##DISO##45.12^M

            00332##LPSO##23.11^M

            01299##USPD##34.46^M

            用一個空格替換所有的##,刪除最前邊的0,刪除尾部^M

            $sed 's/##*/ /g' dos.txt

            $sed 's/^0*/ /g' dos.txt

            $sed 's/\^M//g' dos.txt

            $cat dos.txt |sed 's/##*/ /g'|sed 's/^0*/ /'|sed 's/\^M//g'

            處理報文輸出

            Database      Size(MB)   Date Created

            -------------------------------------

            GOSOUTH       2244       12/11/97

            TRISUD        5632       8/9/99

            (2 rows affected)

            1>使用s/-*//g刪除 -----------

            2>使用/^$/d刪除空行

            3>使用$d刪除最后一行

            4>使用1d刪除第一行

            5>使用awk {print $1}打印第一列

            cat sql.txt | sed 's/--*//g' | sed '/^$/d' | sed '$d' | sed '1d' | awk '{print $1}'

            去除行首數字

            $vi UNH.txt

            12345UND SPLLFC 234344

            9999999UND SKKLT 3423

            1UND SPLLY 434

            $sed 's/^[0-9]*//g' UND.txt

            附加文本每一行末尾加上字符串'passwd'

            vi ok.txt

            AC456

            AC492169

            AC9967

            AC88345

            $sed 's/[0-9]*/& Passwd/g' ok.txt

            從sed輸出中設置shell變量

            $NAME="It's a go situation"

            $REPLACE="GO"

            $NEW_NAME='echo $NAME | sed "s/go/$REPLACE/g"'

            $echo $NEW_NAME

            快速一行命令

            's/\.$//g'       刪除以.結尾的行

            '-e /abcd/d'     刪除包含abcd的行

            's/[][][]*/[]/g' 刪除一個以上的空格,用一個空格代替

            's/^[][]*//g'    刪除行首空格

            's/\.[][]*/[]//g 刪除.后跟2或多個空格,以一個空格代替

            's/COL\(...\)//g'刪除COL和它后邊的3個字母的行

            's/^\//g'        刪除第一個\

            's/[]/[]//g'     刪除所有空格并用tab替代

            's/^[]//g'       刪除行首tab鍵

            's/[]*//g'       刪除所有tab鍵

            插入文本

            $echo "Mr Willis"|sed 's/Mr/& Bruce/g'

            刪除首字符

            $echo "attkla.dc"|sed 's/^./g'

            刪除文件擴展名

            $echo "attkla.dc"|sed 's/.dc//g'

            增加擴展名

            $echo "attkla"|sed 's/$/.dc/g'

            替換字符系列

            $x="Department+payroll%Building G"

            + 換成of %換成located

            $echo $x | sed 's/\+/ of /g' | sed 's/\%/ Located at /g '

                  直接替換
                  sed -i  's/from/to/' filename

            轉自:
            http://blog.chinaunix.net/u/28584/showart.php?id=1712332
            posted on 2009-11-23 21:21 chatler 閱讀(283) 評論(0)  編輯 收藏 引用 所屬分類: Shell
            <2010年1月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(10)

            隨筆分類(307)

            隨筆檔案(297)

            algorithm

            Books_Free_Online

            C++

            database

            Linux

            Linux shell

            linux socket

            misce

            • cloudward
            • 感覺這個博客還是不錯,雖然做的東西和我不大相關,覺得看看還是有好處的

            network

            OSS

            • Google Android
            • Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This early look at the Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.
            • os161 file list

            overall

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久青青草视频| 久久w5ww成w人免费| 色综合久久综精品| 一本大道加勒比久久综合| 久久AAAA片一区二区| 久久综合色之久久综合| 久久偷看各类wc女厕嘘嘘| 中文字幕一区二区三区久久网站| 久久久久女教师免费一区| 蜜桃麻豆WWW久久囤产精品| 久久亚洲中文字幕精品有坂深雪| 久久精品免费大片国产大片| 久久精品国产乱子伦| 国产成人久久精品二区三区| 精品一二三区久久aaa片| 99久久精品免费看国产一区二区三区 | 久久亚洲AV无码西西人体| 欧美亚洲色综久久精品国产| 久久久久久毛片免费看 | 久久99国产综合精品| 久久久久成人精品无码| 久久久久久久亚洲Av无码| 色悠久久久久久久综合网| 亚洲国产精品久久久久网站| 人妻精品久久无码区| 国产精品成人久久久| 亚洲欧美另类日本久久国产真实乱对白| 国产亚洲欧美精品久久久| 伊人久久无码中文字幕| 久久久一本精品99久久精品88| 久久被窝电影亚洲爽爽爽| 久久ZYZ资源站无码中文动漫| 久久亚洲AV成人无码软件| 亚洲欧美国产日韩综合久久| 久久精品国产精品亚洲艾草网美妙| 久久精品草草草| 久久久久久久综合日本亚洲| 国产精品视频久久| 久久美女人爽女人爽| 国产AV影片久久久久久| 久久se精品一区二区影院 |