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

  • SEARCH
  • Home
  • 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 8552783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:30:10+00:00 2026-06-11T14:30:10+00:00

I want a way to search in a given text. For that, I use

  • 0

I want a way to search in a given text. For that, I use grep:

grep -i "my_regex"

That works. But given the data like this:

This is the test data
This is the error data as follows
. . . 
. . . .
. . . . . . 
. . . . . . . . .
Error data ends

Once I found the word error (using grep -i error data), I wish to find the 10 lines that follow the word error. So my output should be:

. . . 
. . . .
. . . . . . 
. . . . . . . . .
Error data ends

Are there any way to do it?

  • 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-06-11T14:30:11+00:00Added an answer on June 11, 2026 at 2:30 pm

    You can use the -B and -A to print lines before and after the match.

    grep -i -B 10 'error' data
    

    Will print the 10 lines before the match, including the matching line itself.

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

Sidebar

Related Questions

When I remove the DOCTYPE line this code works the way I want it
Is there a way that I can search a variable starting from a given
I want to customize my search keyboard in a way that if no input
i have a question that if i want to search a perticular text in
I'm trying to use asp: <asp:TextBox ID=txtInput runat=server TextMode=MultiLine></asp:TextBox> I want a way to
I want a robust way to upload a file. That means that I want
I would like to use CouchDB to store some data for me and then
I'm writing a Cocoa app for Leopard that, given a directory of text files,
I want to be able to do something like <input type=text name=txtField value= title=input
I want to apply a search and replace regular expression pattern that work only

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.