Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7522033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:24:13+00:00 2026-05-30T02:24:13+00:00

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

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:24:14+00:00Added an answer on May 30, 2026 at 2:24 am

    Try this:

    awk 'BEGIN {RS="----->"} /5\. select \* from mytable/ { printf("%s %s",RS,$0)}' INPUT_FILE
    

    If I had understood correctly what you need (print the block, if 5. select * from mytable is in there). If you want a reversed output, try:

    awk 'BEGIN {RS="----->"} ! /5\. select \* from mytable/ { printf("%s %s",RS,$0)}' INPUT_FILE
    

    See it in action here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of filenames in a text file like this: f1.txt f2
I have a bunch of data in a text file like this: 99150, 2012-05-18
I have a text file that has a list of directory names like this:
I have a list of IDs in a text file like this: 24641985 ,
Lets say I have a text file with a list of strings like so:
I have text file like this: 11/18/2012 test1 11/19/2012 test2 11/20/2012 test3 11/21/2012 test4
I have a text file like this: A B C And each element has
if I have a text file like this : this is line one This
I' ve got a problem with Haskell. I have text file looking like this:
I am working with a matlab project. And I have a text file like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.