sed指令取代的問題 - Linux

Steve avatar
By Steve
at 2011-04-05T14:22

Table of Contents

主要是分析lag
它的格式範例大致如下:

-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
5FE7D17E9DC 57621 Mon Mar 28 10:24:56 [email protected]
(connect to aaa.ttt.org[xxx.xxx.xxx.xxx]: Connection refused)
[email protected]

現在要配合分析的程式把第三行的[email protected]
改成 remote [email protected]
remove和[email protected]中間只有要空白隔開即可多少不個空白不重要
試著利用grep和sed是能夠抓到我要的東西並修改
一開始我的寫法是
cat maillist | grep -v '^$' | grep -v '^[0-9A-Z]' | grep -v '(' | grep -v '^-'
| sed 's/^/remote/g'

但這樣寫是把我要的改的東西抓出來改好後輸出
和原本的需求不同
如果要直接寫進log不影響原本的格式
也就是log內容會是
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
5FE7D17E9DC 57621 Mon Mar 28 10:24:56 [email protected]
(connect to aaa.ttt.org[xxx.xxx.xxx.xxx]: Connection refused)
remote [email protected]
直接改掉應該要怎麼寫才好呢?


--
Tags: Linux

All Comments

Queena avatar
By Queena
at 2011-04-07T03:08
重新導向,原po用過 > 了嗎?
Barb Cronin avatar
By Barb Cronin
at 2011-04-12T01:36
重新導向的話只會輸出單純只有remove email的資料
Enid avatar
By Enid
at 2011-04-14T17:35
也就是我要改的東西,但我是希望能在保留log原本的內容下
把我要的東西改掉

gcc 編譯.o 不能執 command not found

Bennie avatar
By Bennie
at 2011-04-05T10:51
===hello.c === #includeandlt;stdio.handgt; #includeandlt;stdlib.handgt; int main(){ prinf(and#34;Helloand#34;); return 0; ===hello.c end=== $g++ hello.c $ ...

VM老問題,麻煩版友指導一下

Selena avatar
By Selena
at 2011-04-04T23:32
不好意思,在Linux界算是新手,想踏進這個領域做研究,有錯或不清楚的地方請指教. 目前小弟在電腦上只有一張網卡,本機電腦是WinXP,目前想在XP上裝VM, VM裡的OS使用CentOS,但目前想要做到的功能是XP出Internet是依靠VM中的CentOS出去. 另外Linux有dhcp功能,我希望能 ...

有關kernel socket的問題

Sarah avatar
By Sarah
at 2011-04-04T19:21
不好意思 請問一下 我在版本2.6.26.5的kernel中插入一個我寫的module 這module是插在ip_rcv 用意是當我收到一個網路上來的封包 我會在此module中呼叫執行sock_sendmsg 也送出一個封包 也就是偵查到收進一個封包就呼叫此函式送出一個封包 原本一切都很正常執行 ...

VM安裝Fedora12遇到i386無法安裝

Todd Johnson avatar
By Todd Johnson
at 2011-04-04T19:08
先見圖~ http://ppt.cc/bE4h 我執行到這個步驟時就出現這個錯誤, 是因為有打勾紅色框框的選項, 有試過沒打勾安裝過去, 而出現沒有終端機可以執行, http://ppt.cc/5sGR 也要另外安裝re-pppoe套件才可進行dsl連線, 我在想是因為沒安裝到i386那套件才 ...

vim 亂碼

Liam avatar
By Liam
at 2011-04-04T18:24
※ 引述《yshihyu (yshihyu)》之銘言: : 我有個.c 檔案註解是簡體 : 但是我在vimrc 設定 : set fileencodings=utf-8,big5,gbk,euc-jp,euc-kr,utf-bom,iso8859-1,cp936 : set encoding=utf8 : s ...