所有的權利,KSH:使用SED返回文本模式
我想寫使用SED一個KSH腳本(我很新的ksh)從日誌翻出這個SQL查詢,但我希望它忽略時間戳和後面的六個字符/空格。這裏是我到目前爲止的代碼...
cat file.log \
| sed -n '/---Query1/,/selected/p' \
| sed 's/^([0-9][0-9]:[0-9][0-9]:[0-9][0-9]??????)//g' \ # My problem
> newfile.log
===Input===
11:23:34 SQL> ---Query1
11:23:34 SQL> select a.column1, b.column2, count(*)
11:23:34 2 from table1 a, table2 b
11:23:34 3 group by a.column1
11:23:34 4 order by 1, 2, 3;
a.column1 a.column2 count(*)
----------- ----------- ----------
foo bar 32
1 row selected.
===Desired Output===
---Query1
select a.column1, b.column2, count(*)
from table1 a, table2 b
group by a.column1
order by 1, 2, 3;
a.column1 a.column2 count(*)
----------- ----------- ----------
foo bar 32
1 row selected.
任何幫助你可以提供非常感謝。
+1樣品輸入/輸出AND代碼。繼續發帖,祝你好運。 – shellter 2013-05-06 18:30:27