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 8281029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:53:35+00:00 2026-06-08T09:53:35+00:00

Okay so I can’t figure this out. Like a file that I using grep

  • 0

Okay so I can’t figure this out. Like a file that I using grep in order to get certain information has it set-up like this.

#aaaa
<numbers 123456>

blah
blah
blah

#bbbb
<numbers 2156488>

blah
blah
blah

#cccc
<numbers 5478624>

blah
blah
blah

What I am doing is I am greping for aaaa or bbbb or cccc and the information that i really need is the numbers. As in when i grep for aaaa the thing i want to obtain is really just the numbers right below it. In this case it would 123456

I know how to grep for aaaa but i don’t know how to go to the next line and cut the number.

  • 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-08T09:53:36+00:00Added an answer on June 8, 2026 at 9:53 am

    You can use the -C option of grep to show one line of context. Then you can tail on the last line (-n 1), cut using spaces and selecting the second field, cut again using > and selecting the first field. Thus:

    $ grep aaaa file -C 1 | tail -n 1 | cut -f2 -d' ' | cut -d'>' -f1
    123456
    

    will give back the number you’re requesting.

    The most important part is the -C option of grep

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

Sidebar

Related Questions

Okay, for whatever reason I can't seem to figure this little problem out. I
Okay so i set up this thing so that I can print out page
Okay people, I'm sure someone has had this issue and can help me out.
Okay I almost have this rebase thing figured out. I can feel a breakthrough
Okay, this should be simple, but I just can't get it to work. I
Okay guys, maybe you can help me out with this one. I'm about ready
Okay, I believe that I can simplify this line of code except I can't
Okay, this is probably a very newbie question, but how can I get to
Okay been working on this too long and can't get it to work. I
Okay, I know I'm doing something wrong - but can't figure out a better

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.