Let's imagine I have a text file with records taken from different sources. The file looks like this:
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.
Each row starts with \n
and a row number like {1000...2000}. The row number is separated from text with a tab \t
.
So how do I count the occurrence of "."
with sed in one record
?
Can sed substitute all chars except the ones that are given in a pattern without grouping them in into [^...]
?
The output should look like this:
1000 1
1001 1
1002 2
1003 2
1004 3