Sunday, November 28, 2010

filter txt file based on start and ending marks

Hi,

When I compile my VHDL design I get a large log file which I want to filter.
Is it possible to do this?
I was wondering to search for certain patterns in the log file and
provide a start and end mark for the interresting stuff.
And then delete all that isn't in the selected sections.
Is that possible?

For example, if the text is this:
+--- START OF LOG ---+
[...]
Not interesting stuff.
[...]
AAA ... BBB ... CCC
[...]
Interesting stuff.
[...]
DDD .... EEE
[...]
Not interesting stuff.
[...]
FFF
[...]
Interesting stuff.
[...]
GGG ... HHH
[...]
Not interesting stuff.
[...]
KKK ... LLL ... MMM ... NNN
[...]
Interesting stuff.
[...]
PPP ... QQQ ... RRR
+--- END OF LOG ---+

1) Can you then search for a pattern that starts with AAA and then
followed by BBB and ending with CCC and place a start mark to select
the line
AAA ... BBB ... CCC
(... means any kind of text, but not AAA, BBB or CCC)

2) And then place an end mark at the line
DDD .... EEE

3) Do the same for FFF (place here a start mark) and GGG ... HHH
(place an end mark)
4) Do the same for KKK ... LLL ... MMM ... NNN (place a start mark)
and PPP ... QQQ ... RRR (place an end mark)

5) Now you have a log file with start and ending marks. How to delete
the selection that are not in the start and ending marks?
Or if that's easier, how to copy the sections marked to a new file?

So that the new log file is as:
+--- START OF LOG ---+
AAA ... BBB ... CCC
[...]
Interesting stuff.
[...]
DDD .... EEE
FFF
[...]
Interesting stuff.
[...]
GGG ... HHH
KKK ... LLL ... MMM ... NNN
[...]
Interesting stuff.
[...]
PPP ... QQQ ... RRR
+--- END OF LOG ---+


Rgds,
Jeri

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment