Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Add numbers in third code with conditions on the 1st and 2nd Post 302883306 by TheTransporter on Monday 13th of January 2014 08:40:31 AM
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...
 

We Also Found This Discussion For You

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
COLRM(1)						    BSD General Commands Manual 						  COLRM(1)

NAME
colrm -- remove columns from a file SYNOPSIS
colrm [start [stop]] DESCRIPTION
The colrm utility removes selected columns from the lines of a file. A column is defined as a single character in a line. Input is read from the standard input. Output is written to the standard output. If only the start column is specified, columns numbered less than the start column will be written. If both start and stop columns are spec- ified, columns numbered less than the start column or greater than the stop column will be written. Column numbering starts with one, not zero. Tab characters increment the column count to the next multiple of eight. Backspace characters decrement the column count by one. ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of colrm as described in environ(7). EXIT STATUS
The colrm utility exits 0 on success, and >0 if an error occurs. SEE ALSO
awk(1), column(1), cut(1), paste(1) HISTORY
The colrm command appeared in 3.0BSD. BSD
August 4, 2004 BSD
All times are GMT -4. The time now is 06:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy