I have a text file like list:
-----> 2012-02-13 19:29:27.325 <http-0.0.0.0-9090-1> at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:236)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:187)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
.... (many lines starts with at)
5. select * from mytable
-----> 2012-02-13 19:31:27.325 <http-0.0.0.0-9090-1> at
... (many lines start with at, just like above)
I want to print the block of lines starting with -----> 2012-02-13 if the line starting with 5. select contains the keyword mytable.
How to do that with awk?
Try this:
If I had understood correctly what you need (print the block, if
5. select * from mytableis in there). If you want a reversed output, try:See it in action here.