Add numbers in third code with conditions on the 1st and 2nd


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Add numbers in third code with conditions on the 1st and 2nd
Prev   Next
# 1  
Old 01-13-2014
Add numbers in third code with conditions on the 1st and 2nd

Hello all,

I have a file with three columns, in which the first column has one letter from A-Z, the second one letter from A-Z, and the third a number:
e.g.
Code:
A A 5
A B 6
A C 1
A D 7
B A 8

The desired output is:
Code:
A A 5
A B 14
A C 1
A D 7

Just because A B and B A are essentially the same.

Is there a way to do this in awk or bash?

Thank you

Last edited by vbe; 01-13-2014 at 09:48 AM.. Reason: code tags...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Want the UNIX code - I want to sum of the 1st column wherever the first 2nd and 3rd columns r equal

I have the code for the below things.. File1 has the content as below 8859 0 subscriberCreate 18 0 subscriberPaymentMethodChange 1650 0 subscriberProfileUpdate 7668 0 subscriberStatusChange 13 4020100 subscriberProfileUpdate 1 4020129 subscriberStatusChange 2 4020307 subscriberCreate 8831... (5 Replies)
Discussion started by: Mahen
5 Replies
Login or Register to Ask a Question
GIT-COLUMN(1)							    Git Manual							     GIT-COLUMN(1)

NAME
git-column - Display data in columns SYNOPSIS
git column [--command=<name>] [--[raw-]mode=<mode>] [--width=<width>] [--indent=<string>] [--nl=<string>] [--padding=<n>] DESCRIPTION
This command formats its input into multiple columns. OPTIONS
--command=<name> Look up layout mode using configuration variable column.<name> and column.ui. --mode=<mode> Specify layout mode. See configuration variable column.ui for option syntax. --raw-mode=<n> Same as --mode but take mode encoded as a number. This is mainly used by other commands that have already parsed layout mode. --width=<width> Specify the terminal width. By default git column will detect the terminal width, or fall back to 80 if it is unable to do so. --indent=<string> String to be printed at the beginning of each line. --nl=<N> String to be printed at the end of each line, including newline character. --padding=<N> The number of spaces between columns. One space by default. AUTHOR
Written by Nguyen Thai Ngoc Duy <pclouds@gmail.com[1]> GIT
Part of the git(1) suite NOTES
1. pclouds@gmail.com mailto:pclouds@gmail.com Git 1.8.3.1 06/10/2014 GIT-COLUMN(1)