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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:36:15+00:00 2026-06-07T05:36:15+00:00

I have a text file which goes like this : 125 126 127 {

  • 0

I have a text file which goes like this :

      125
      126
      127    {
      566
      567
      568
      569       # blah blah
      570    {  #blah blah
      700
      701    {

The numbers are left aligned and the pattern is always the same in the sense increasing and a curly braces at the end .I need to catch just the starting number .The braces are always found and limited to the sequence end .The start of the file is as shown starting with ‘125’.

In short I need :

      125
      566
      700

What I have come up with :

      grep -A1 '{' | grep -v '{' | grep -oE '(^[0-9]+?)'

but this omits ‘125’ but I overcame by appending a newline at the head and inserting a { .

I hope to reduce this into a single regex.

Suggestions and better algorithms are welcome

  • 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-07T05:36:16+00:00Added an answer on June 7, 2026 at 5:36 am
    awk 'BEGIN {p=1} p==1 {print $1;p=0} $0~/{/ {p=1}'
    
    Output:
    125
    566
    700
    

    Given the file format above, you could use awk and a variable/flag to keep track on when you find an opening {

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

Sidebar

Related Questions

I have a text file which contains something like this: Hello, my name is
I have a text file which has a particular line something like sometext sometext
I have a text file which I am reading and storing the data in
I have a text file which contains data seperated by '|'. I need to
I have a text file which I want to filter using awk. The text
I have a text file which needs to be constantly updated (regular intervals). All
I have a text file in which a particular character repeats at the start
I have a huge text file which I want to explode into an array.
I have a text file (tab separated) which consist of 17 column. I would
I have a single big text file in which I want to process each

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.