sed指令取代的問題 - Linux

By Steve
at 2011-04-05T14:22
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]
直接改掉應該要怎麼寫才好呢?
--
它的格式範例大致如下:
-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

By Queena
at 2011-04-07T03:08
at 2011-04-07T03:08

By Barb Cronin
at 2011-04-12T01:36
at 2011-04-12T01:36

By Enid
at 2011-04-14T17:35
at 2011-04-14T17:35
Related Posts
gcc 編譯.o 不能執 command not found

By Bennie
at 2011-04-05T10:51
at 2011-04-05T10:51
VM老問題,麻煩版友指導一下

By Selena
at 2011-04-04T23:32
at 2011-04-04T23:32
有關kernel socket的問題

By Sarah
at 2011-04-04T19:21
at 2011-04-04T19:21
VM安裝Fedora12遇到i386無法安裝

By Todd Johnson
at 2011-04-04T19:08
at 2011-04-04T19:08
vim 亂碼

By Liam
at 2011-04-04T18:24
at 2011-04-04T18:24