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
readkey(3alleg4)                                                  Allegro manual                                                  readkey(3alleg4)

NAME
readkey - Returns the next character from the keyboard buffer. Allegro game programming library. SYNOPSIS
#include <allegro.h> int readkey(); DESCRIPTION
Returns the next character from the keyboard buffer, in ASCII format. If the buffer is empty, it waits until a key is pressed. You can see if there are queued keypresses with keypressed(). The low byte of the return value contains the ASCII code of the key, and the high byte the scancode. The scancode remains the same whatever the state of the shift, ctrl and alt keys, while the ASCII code is affected by shift and ctrl in the normal way (shift changes case, ctrl+letter gives the position of that letter in the alphabet, eg. ctrl+A = 1, ctrl+B = 2, etc). Pressing alt+key returns only the scan- code, with a zero ASCII code in the low byte. For example: int val; ... val = readkey(); if ((val & 0xff) == 'd') /* by ASCII code */ allegro_message("You pressed 'd' "); if ((val >> 8) == KEY_SPACE) /* by scancode */ allegro_message("You pressed Space "); if ((val & 0xff) == 3) /* ctrl+letter */ allegro_message("You pressed Control+C "); if (val == (KEY_X << 8)) /* alt+letter */ allegro_message("You pressed Alt+X "); This function cannot return character values greater than 255. If you need to read Unicode input, use ureadkey() instead. SEE ALSO
install_keyboard(3alleg4), ureadkey(3alleg4), keypressed(3alleg4), clear_keybuf(3alleg4), simulate_keypress(3alleg4) Allegro version 4.4.2 readkey(3alleg4)
All times are GMT -4. The time now is 02:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy