我們假設我有一個文本文件,其中包含來自不同來源的記錄。該文件是這樣的:如何計算跨越多行sed的記錄中的點?
1000 Once upon a time, happy end.
1001 Tornado in NY city, the statue was finally found.
1002 I bought her an iphone
yes
for $1000. And then
happy end.
1003 How many times
have I seen it?
not many. Actually.
1004 5 Cars. 2 Toys. 3 Birds.
每一行與\n
開始,如{1000 ... 2000}行號。行號與標籤\t
分開。
那麼如何計算"."
與sed的出現在一個record
?
可以sed替換所有字符,除了在模式中給出的字符而不將它們分組到[^...]
?
輸出應該是這樣的:
1000 1
1001 1
1002 2
1003 2
1004 3
入住這http://stackoverflow.com/a/1603638/171318 – hek2mgl 2013-04-10 14:19:01
謝謝,但它不是我想在這裏做什麼。我需要統計一條記錄中的事件。 – minerals 2013-04-10 14:33:24
好吧,那麼我沒有得到這個問題,因爲它的目的是 – hek2mgl 2013-04-10 14:42:19