Sponsored Content
Full Discussion: Sum in file based column
Top Forums UNIX for Beginners Questions & Answers Sum in file based column Post 303039372 by arunkumar_mca on Wednesday 2nd of October 2019 11:25:02 AM
Old 10-02-2019
Thanks . When I tried to print the description using the below command I am getting only one description not sure what I am doing wrong
Code:
awk -F'[;]' '{ t[$1]+=$3 } END { for (i in t) print i,$2, t[i] }'  my file

INPUT
10264;ATE;12
10265;SES;11
10266;AUT;50
10264;ATE;10
10265;SES;13
10266;AUT;89
10264;ATE;1
10265;SES;15
10266;AUT;78


OUTPUT
10266 AUT 217
10264 AUT 23
10265 AUT 39

Expected
10266 AUT 217
10264 ATE 23
10265 SES 39

Also if I have the number as 1009090992.1111 the my result is coming as 1.00909e+09 how to get that as a whole number
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I sum one column based on another column?

Hi, I am new to this forum and new to awk. I have a file that contains 2 columns. Heres an example of what it looks like: 10 + 20 + 40 + 50 - 70 - So the file is tab-delimited. What I want to do is add 10 to column 1 whenever column 2 is + and substract 10 from column 1... (1 Reply)
Discussion started by: phil_heath
1 Replies

2. Shell Programming and Scripting

sum multiple columns based on column value

i have a file - it will be in sorted order on column 1 abc 0 1 abc 2 3 abc 3 5 def 1 7 def 0 1 -------- i'd like (awk maybe?) to get the results (any ideas)??? abc 5 9 def 1 8 (2 Replies)
Discussion started by: jjoe
2 Replies

3. Shell Programming and Scripting

Sum a column value based on multiple keys

Hi, I have below as i/p file: 5ABC 36488989 K 000010000ASB BYTRES 5PQR 45757754 K 000200005KPC HGTRET 5ABC 36488989 K 000045000ASB HGTRET 5GTH 36488989 K 000200200ASB BYTRES 5FTU ... (2 Replies)
Discussion started by: nirnkv
2 Replies

4. Shell Programming and Scripting

Sum Of Column Based On Column Condition

I have a following inputfile MT,AP,CDM,TTML,MUM,GS,SUCC,3 MT,AP,CDM,TTSL,AP,GS,FAIL,9 MT,AP,CDM,RCom,MAH,GS,SUCC,3 MT,AP,CDM,RTL,HP,GS,SUCC,1 MT,AP,CDM,Uni,UPE,GS,SUCC,2 MT,AP,CDM,Uni,MUM,GS,SUCC,2 TTSL,AP,GS,MT,MAH,CDM,SUCC,20 TTML,AP,GS,MT,MAH,CDM,FAIL,10... (2 Replies)
Discussion started by: siramitsharma
2 Replies

5. UNIX for Dummies Questions & Answers

Sum based on column 1

i have file input aaa ccc,45567,rterw,1 bbb dcs,564543,hjghgh,1 aaa ccc,454,rterw,6 i want to sum based on column 1 expected output aaa ccc,7 bbb dcs,1 (4 Replies)
Discussion started by: radius
4 Replies

6. UNIX for Dummies Questions & Answers

Sum based on certain column

I have file 1 1/1/2013 A 553.0763397 96 16582 X1 X3 X5 X7 X9 1/1/2013 B 600.8333588 195 11992 X2 X3 X6 X7 X9 1/1/2013 B 459.8333588 195 11992 X1 X3 X6 X7 X9 1/2/2013 A 844.2973022 306 19555 X1 ... (12 Replies)
Discussion started by: radius
12 Replies

7. Shell Programming and Scripting

awk to sum a column based on duplicate strings in another column and show split totals

Hi, I have a similar input format- A_1 2 B_0 4 A_1 1 B_2 5 A_4 1 and looking to print in this output format with headers. can you suggest in awk?awk because i am doing some pattern matching from parent file to print column 1 of my input using awk already.Thanks! letter number_of_letters... (5 Replies)
Discussion started by: prashob123
5 Replies

8. UNIX for Dummies Questions & Answers

Sum third column in a file when 1 and 2 repeat

Hello, Below is a portion of a file I am working on: 2:15 3001 120 2:15 3001 26.25 2:15 3002 12.5 2:15 3002 15 9:45 3001 45 9:45 3001 45 9:45 3002 105 9:45 3005 180 9:45 3005 123.75 9:45 3005 15 I am trying to get the sum of column 3 for all repeated values of columns 1 and 2 (The... (6 Replies)
Discussion started by: c@rlos
6 Replies

9. Shell Programming and Scripting

Sum column values based in common identifier in 1st column.

Hi, I have a table to be imported for R as matrix or data.frame but I first need to edit it because I've got several lines with the same identifier (1st column), so I want to sum the each column (2nd -nth) of each identifier (1st column) The input is for example, after sorted: K00001 1 1 4 3... (8 Replies)
Discussion started by: sargotrons
8 Replies

10. Shell Programming and Scripting

Sum of a column as new column based on header in a script

Hello, I am trying to store sum of a column as a new column inside a file but have to find the column names dynamically I/p c1,c2,c3,c4,c5 10,20,30,40,50 20,30,40,50,60 If i want to find sum only column c1, c3 and output it as c6,c7 O/p c1,c2,c3,c4,c5,c6,c7 10,20,30,40,50,30,70... (6 Replies)
Discussion started by: mkathi
6 Replies
ledctl(8)					    Intel(R) Enclosure LED Control Application						 ledctl(8)

NAME
ledctl - Intel(R) LED control application for a storage enclosures. SYNOPSIS
ledctl [OPTIONS] pattern_name=list_of_devices ... DESCRIPTION
The ledctl is an user space application designed to control LEDs associated with each slot in an enclosure or a drive bay. The LEDs of devices listed in list_of_devices are set to the given pattern pattern_name and all other LEDs are turned off. User must have root privileges to use this application. There are two types of systems: 2-LEDs systems (Activity LED, Status LED) and 3-LEDs systems (Activity LED, Locate LED, Fail LED). The ledctl application uses SGPIO and SES-2 protocol to control LEDs. The program implements IBPI patterns of SFF-8489 specification for SGPIO. Please note some enclosures do not stick close to SFF-8489 specification. It might happen that enclosure's processor will accept an IBPI pattern but it will blink the LEDs at variance with SFF-8489 specification or it has limited number of patterns supported. LED management (AHCI) and SAF-TE protocols are not supported. The ledctl application has been verified to work with Intel(R) storage controllers (i.e. Intel(R) AHCI controller and Intel(R) SAS controller). The application might work with storage controllers of other vendors (especially SCSI/SAS controllers). However, storage controllers of other vendors have not been tested. The ledmon application has the highest priority when accessing LEDs. It means that some patterns set by ledctl may have no effect if ledmon is running (except Locate pattern). The ledctl application is a part of Intel(R) Enclosure LED Utilities. Pattern Names The ledctl application accepts the following names for pattern_name argument according to SFF-8489 specification. locate Turns Locate LED associated with the given device(s) or empty slot(s) on. locate_off Turns only Locate LED off. normal Turns Status LED, Failure LED and Locate LED off. off Turns only Status LED and Failure LED off. ica or degraded Visualizes "In a Critical Array" pattern. rebuild or rebuild_p Visualizes "Rebuild" pattern. ifa or failed_array Visualizes "In a Failed Array" pattern. hotspare Visualizes "Hotspare" pattern. pfa Visualizes "Predicted Failure Analysis" pattern. failure or disk_failed Visualizes "Failure" pattern. ses_abort SES-2 R/R ABORD ses_rebuild SES-2 REBUILD/REMAP ses_ifa SES-2 IN FAILED ARRAY ses_ica SES-2 IN CRIT ARRAY ses_cons_check SES-2 CONS CHECK ses_hotspare SES-2 HOT SPARE ses_rsvd_dev SES-2 RSVD DEVICE ses_ok SES-2 OK ses_ident SES-2 IDENT ses_rm SES-2 REMOVE ses_insert SES-2 INSERT ses_missing SES-2 MISSING ses_dnr SES-2 DO NOT REMOVE ses_active SES-2 ACTIVE ses_enbale_bb SES-2 ENABLE BYP B ses_enable_ba SES-2 ENABLE BYP A ses_devoff SES-2 DEVICE OFF ses_fault SES-2 FAULT Patterns Translation When non SES-2 pattern is send to device in enclosure automatic translation is being done. locate locate is translated to ses_ident locate_off locate_off is translated to ~ses_ident normal normal is translated to ses_ok off off is translated to ses_ok degraded degraded is translated to ses_ica rebuild rebuild is translated to ses_rebuild rebuild_p rebuild_p is translated to ses_rebuild failed failed is translated to ses_ifa hotspare hotspare is translated to ses_hotspare pfa pfa is translated to ses_rsvd_dev failure failure is translated to ses_fault disk_failed disk_failed is translated to ses_fault List of Devices The application accepts a list of devices in two formats. The first format is a list with comma separated elements. The second format is a list in curly braces and elements are separated by space. See examples section bellow for details. A device is a path to file in /dev directory or in /sys/block directory. It may identify a block device, a RAID device or a container device. In case of a RAID device or a container device a state will be set for all block devices associated, respectively. The LEDs of devices listed in list_of_devices are set to the given pattern pattern_name and all other LEDs are turned off. OPTIONS
-c or --config=path Sets a path to local configuration file. If this option is specified the global configuration file and user configuration file has no effect. -l or --log=path Sets a path to local log file. If this option is specified the global log file /var/log/ledctl.log is not used. -h or --help Prints this text out and exits. -v or --version Displays version of ledctl and information about the license and exits. FILES
/var/log/ledctl.log Global log file, used by all instances of ledctl application. To force logging to user defined file use -l option switch. ~/.ledctl User configuration file, shared between ledmon and all ledctl application instances. /etc/ledcfg.conf Global configuration file, shared between ledmon and all ledctl application instances. EXAMPLES
The following example illustrates how to locate a single block device. ledctl locate=/dev/sda The following example illustrates how to turn Locate LED off for the same block device. ledctl locate_off=/dev/sda The following example illustrates how to locate disks of a RAID device and how to set rebuild pattern for two block devices at the same time. This example uses both formats of device list. ledctl locate=/dev/md127 rebuild={ /sys/block/sd[a-b] } The following example illustrates how to turn Status LED and Failure LED off for the given device(s). ledctl off={ /dev/sda /dev/sdb } The following example illustrates how to locate a three block devices. This example uses the first format of device list. ledctl locate=/dev/sda,/dev/sdb,/dev/sdc LICENSE
Copyright (c) 2009-2013 Intel Corporation. This program is distributed under the terms of the GNU General Public License as published by the Free Software Foundation. See the built- in help for details on the License and the lack of warranty. SEE ALSO
ledmon(8), ledctl.conf(5) AUTHOR
This manual page was written by Artur Wojcik <artur.wojcik@intel.com>. It may be used by others. LEDCTL Version 0.79 November 2013 ledctl(8)
All times are GMT -4. The time now is 09:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy