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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:16:29+00:00 2026-05-29T18:16:29+00:00

I need to find a value in a file that has an id (say

  • 0

I need to find a value in a file that has an id (say valueID1) and is less than a certain value. From that, I need to find the first value that is associated with valueID1 but has a different value id and is on a different line (say valueID2)

Say I wanted to find an id in the file called “birthday”, such as birthday = xx/xx/xxxx I’d want to find the first birthday below a specific date (I’d have to use $3 to grab the actual numeric value) Then, I would want to grab the value of the second id that is near the first, so “name” as in “name = Greg.” I’d want to output ‘Greg’ there. I only want the first result, not all of the results less than the first specified value.

Any thoughts on how to do this? This is all I’ve been able to do, and it doesn’t work at all.

{
 if((/valueID1/ $3) < 0.1) print /valueID2/ $3; else
       /valueID2/
}
  • 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-29T18:16:30+00:00Added an answer on May 29, 2026 at 6:16 pm

    Here are what I understand from your description, your data might look something like this:

    Birthday = 2011
    Name = Anna
    Birthday = 1987
    Name = George
    

    In this case, you want to print out “George” because his birthday is less than 1999. If these assumptions are correct, here is how I solve it:

    awk '$1=="Birthday"{birthday = $3} $1=="Name" && birthday<1999 {print $3}' birthday.txt
    

    Discussion

    • I assume your data file is called birthday.txt
    • The first part $1==”Birthday”{birthday = $3} saves the birthday field into the variable birthday
    • Next, if the line contains “Name” we check the birthday which we saved and print

    Update

    If the year is always the last field, the the following would work. If it is still not working, please supply input data and expected output. It is hard to give accurate result when I don’t fully understand the problem. Good luck.

    awk '/BirthdayYear/{birthday=$NF} $1=="Name" && birthday<1999 {print $3}' birthday.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to find a regular expression which pulls out a value from a
I need to read from a file and find a word in it. The
I have a situation where I need to find the value with the key
I have a matrix in MATLAB and I need to find the 99% value
I need to find out the maximum and minimum value in a line by
I have a PMS(Pantone Matching System) color value. I need to find the corresponding
I need a VBA function that will perform the following: Find all unique values
Need to find the timestamp for the first minute of the first day of
I need to find a way to spin off a thread from a static
I need to open a html help file from within a legacy windows application

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.