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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:02:19+00:00 2026-06-13T12:02:19+00:00

I am beginner in AWK , so please help me to learn it. I

  • 0

I am beginner in AWK, so please help me to learn it. I have a text file with name snd and it values are

1 0 141
1 2 223
1 3 250
1 4 280

I want to print the entire row when the third column value is minimu

  • 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-13T12:02:20+00:00Added an answer on June 13, 2026 at 12:02 pm

    This should do it:

    awk 'NR == 1 {line = $0; min = $3}
         NR > 1 && $3 < min {line = $0; min = $3}
         END{print line}' file.txt
    

    EDIT:

    What this does is:

    • Remember the 1st line and its 3rd field.
    • For the other lines, if the 3rd field is smaller than the min found so far, remember the line and its 3rd field.
    • At the end of the script, print the line.

    Note that the test NR > 1 can be skipped, as for the 1st line, $3 < min will be false. If you know that the 3rd column is always positive (not negative), you can also skip the NR == 1 ... test as min‘s value at the beginning of the script is zero.

    EDIT2:

    This is shorter:

    awk 'NR == 1 || $3 < min {line = $0; min = $3}END{print line}' file.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Beginner question: I have a dictionary where the values are lists of (a variable
Beginner to assembly programming for x86. I have a simple asm file which I
Beginner android question. Ok, I've successfully written files. E.g. // get the file name
Python beginner, I have become familiar with reading through a file and doing basic
I am a beginner in using Linux, I have an input file with content
Beginner testng always add the parameter error Master please help look at Thank you!!
Beginner iOS dev here. I have a problem in my array. Im making an
Beginner in Android development. My code crashes. I have made a simple Java method
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Beginner help needed :) I am doign an example form a php book which

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.