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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:42:00+00:00 2026-06-15T12:42:00+00:00

I would like to print $1 and $2 if $2<25 from text files. I

  • 0

I would like to print $1 and $2 if $2<25from text files. I also need to get the total number of students with marks less than 25 from all files. How can I do this with awk or sed?

students  marks
jerry     12
peter     35
john      5
jerry     15
john      10

Desired output

jerry    12
john      5 
jerry     15
john      10

Total no:of students :- 4
  • 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-15T12:42:00+00:00Added an answer on June 15, 2026 at 12:42 pm

    In awk:

    $ awk '$2<25 {print; i++} END{print "\nTotal number of students:- "i}' file
    

    Output:

    jerry     12
    john      5
    jerry     15
    john      10
    
    Total number of students:- 4
    

    If you want the output sorted by grade (lowest to highest):

    $ sort -n -k2,2 file | awk '$2<25 {print; i++} END{print "\nTotal number of students:- "i}' 
    

    Sorted Output:

    john      5
    john      10
    jerry     12
    jerry     15
    
    Total number of students:- 4
    

    -n numerical sort;
    -k2,2 sort on the second field.

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

Sidebar

Related Questions

I have PDB(text) files which are in a directory. I would like to print
I would like to print raw phone number record (31999999) as 31-999-999 (PHP). I
Simple question, I would like to append text to the front of every print
I would like to take text from a file and then send it to
Suppose there is a large text file and I would like to print only
I have pdf page I would like to print/save from the C# windows forms
I have 100 text files which look like this: File title 4 Realization number
I would like to print the size of the root volume set by GetDiskFreeSpaceEx(...),
I would like to print a message if either a or b is empty.
I would like to print scrollable div as WYSWYG. Is there a way?

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.