Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
Print the fist row with check the condition in awk command

File in content is

safwan@hello:~/linx$ cat 5.txt 
Name    age address email
safwan  25  India   safwan@gmail.com
Ajmal   23  India   ajmal@gmil.com

Apply a condition

awk '$2==25 {print}' 5.txt

output is

safwan@hello:~/linx$ awk '$2==25 {print}' 5.txt 
safwan  25  India   safwan@gmail.com

But I need also the first row

I expect the output is like

Name    age address email
safwan  25  India   safwan@gmail.com
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can evaluate if NR == 1 or your actual condition to get the header row with your data row:

awk 'NR == 1 || $2 == 25' 5.txt

Besides there is no need to use {print} as that is the default action in awk.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!