Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Add numbers in third code with conditions on the 1st and 2nd Post 302883330 by Yoda on Monday 13th of January 2014 10:20:11 AM
Old 01-13-2014
Code:
awk '
        {
                i = $2 FS $1
                if ( i in A )
                {
                        A[i] += $3
                        next
                }
                else
                        A[$1 FS $2] += $3
        }
        END {
                for ( k in A )
                        print k, A[k]
        }
' file

These 2 Users Gave Thanks to Yoda For This Post:
 

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
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. GIT
Part of the git(1) suite Git 2.17.1 10/05/2018 GIT-COLUMN(1)
All times are GMT -4. The time now is 01:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy