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

230
Views
Sum columns and show totals with label with AWK

I have a file with:

1 Inicio
1 Fin
1 Starting
1 Ending
2 Inicio
2 Fin
2 Starting
2 Ending
6 OK
4 OK

But I need

3 Inicio
3 Fin
3 Starting
3 Ending
10 OK

I try with

awk '{ sum+=$1} END {print "Total " sum}' /myfile.txt

But this returned the total of coincidences. I appreciate your help .

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use awk like this:

awk '{sums[$2] += $1} END{for (i in sums) print sums[i], i}' file

3 Inicio
3 Starting
3 Fin
3 Ending
10 OK
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!