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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:51:55+00:00 2026-06-08T19:51:55+00:00

I have 2 files that looks like this: file1 aaa 5 bbb 2 ccc

  • 0

I have 2 files that looks like this:

file1

aaa 5
bbb 2
ccc 9
ddd 46
eee 89
fff 56

file 2

aaa 54
bbb 8
ccc 16
ddd 4
eee 66
fff 9

I would like to have the sum of specific columns
(for example sum of aaa in both files
and sum of ccc + sum of ddd
and sum of bbb + sum of eee + sum of fff)

Is there a simple way to do so with awk for example?

  • 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-08T19:51:57+00:00Added an answer on June 8, 2026 at 7:51 pm

    If you simply want the sums, this can be done in pure bash (using associative arrays here, so bash 4 is required):

    declare -A sums
    while read name val1 val2; do
      sums[$name]=$(( val1 + val2 ))
    done < <(join -j 1 file1 file2)
    
    echo "Sum of aaa: ${sums[aaa]}"
    echo "Sums of ccc and ddd: $(( ${sums[ccc]} + ${sums[ddd]} ))"
    echo "Sums of bbb, eee, and fff: $(( ${sums[bbb]} + ${sums[eee]} + ${sums[fff]} ))"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi, I have a input that looks like this : <input type=file id=ModelViewAd.Files[0] name=ModelViewAd.Files[0]
I have to process JSON files that looks like this: \u0432\u043b\u0430\u0434\u043e\u043c <b>\u043f\u0443\u0442\u0438\u043c<\/b> \u043d\u0430\u0447 Unfortunately,
I have a file that contain lines that looks like this: >AF001546_1 [88 -
I have a file that contain list of numbers that looks like this: 10^-92
I have a data file that looks like this: xyz123 2.000 -0.3974 0.0 hij123
I have a text file that looks like this. A 102 B 456 C
I have a file structure that looks like this ./501.res/1.bin ./503.res/1.bin ./503.res/2.bin ./504.res/1.bin and
I have a text file that looks like this: value1 value2 value3 There are
I have a php file that looks like this: <?php include(config.php); // put the
I have an XML file that looks like this: <SiteMenuItems> <SiteMenuItem text=Home navigateurl=/Default.aspx tooltip=Return

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.