首頁 | 營銷 | I.T. | 玄學 | 雜記 | | 奇人異士 | 補鈣基楚 | 松たか子 | 相冊 | 登陸
公告

>> 本 BLOG 已經停用 <<

援助四川地震災民

請 ROOT LAU 的朋友注意

聯絡 ROOT LAU 須知事項

想擁有自己的 BLOG 及網址?
可以到以下的網址:
http://per.st

ROOT LAU
傅真:(852) 3016 1394
SkyPE:rootlau
MSN: rootlau @hotmail.com
ICQ:20215381










統計信息
日誌: 62
評論: 105
到訪: 576729 [統計]
今日: 21
用戶: 24 [列表]
在線: 4
日曆
2010 - 09
   1234
567891011
12131415161718
19202122232425
2627282930  
最新日誌
最新評論
最新回響
搜索
歸檔
友情連結
雜項
Get RSS Feed (Version 1.0)
Get RSS Feed (Version 2.0)
Get Atom Feed (Version 0.3)
編碼:  UTF-8
Creative Commons
Powered by Bo-Blog V1.7.0100
在 Linux 的 shell 上搜尋文字並替代
天氣2007年11月4日05:49星期日  [I.T.]

今天真的忙過死去活來!在決定放棄使用 Pacific Internet 的寬頻而改用 PCCW 的一刻,已經知道會有這一天的來臨‧‧‧ 無耐 Pacific Internet 實在不爭氣,連我這個 Reseller Partner 也要‧‧‧

接著就是要將我的 Servers (幾部) 的網絡設定,DNS,HTTPD,SENDMAIL,‧‧‧ 全部也要將 IP 更換下來,痛苦‧‧‧

幸好徙網路上找到了一個可以將文字更換的程式,工作就可以比較輕鬆地完成!

#!/bin/bash
        #       This script will search and replace all regular files for a string
        #       supplied by the user and replace it with another string.
        #
        #       Written by Daniel McCarthy
        #      
daniel.mccarthy@linuxphile.org
        #
        function usage {
                echo ""
                echo "Search/replace script"
                echo "    Written by Daniel McCarthy"
                echo "     
daniel.mccarthy@linuxphile.org"
                echo "     
http ://linuxphile.org"
                echo ""
                echo "Not enough parameters provided."
                echo "Usage: ./$0 searchstring replacestring"
                echo "Remember to escape any special characters in the searchstring or the replacestring"
                echo ""
        }

        #check for required parameters
        if  [ ${ #1 } -gt 0  ]  &&  [ ${ #2 } -gt 0  ];
        then
        for f in `find  -type f`;
        do
                if grep -q $1 $f;
                then
                        cp $f $f.bak
                        echo "The string $1 will be replaced with $2 in $f"
                        sed s/$1/$2/g < $f.bak > $f
                        rm $f.bak
                fi
        done

        else
        #print usage informamtion
        usage
fi

參考:http://linuxphile.org/node/13


字體:

Permanant URI永久地址 http://blog.rootlau.com/o......cleid=a_20071104_194958
Trackback URI引用地址 http://blog.rootlau.com/old/tb.php?tb_id=1194176998

Posted by rootlau | 評論(0) | 引用(7) | 閱讀496次
提示:
此文還沒有評論。

稱呼:    登陸
   記住我
郵件:
(非必須)
評論: [UBB代碼幫助]
粗體 斜體 下劃線 鏈接 水平線 引用



驗證碼: 請輸入你看見的數字
關閉UBB      提交時自動將內容複製到剪貼板