Sponsored Content
Full Discussion: Summing values in columns
Top Forums Shell Programming and Scripting Summing values in columns Post 302546714 by rangarasan on Friday 12th of August 2011 01:52:07 AM
Old 08-12-2011
Tools Summing Values in column

Hi,

Code:
nawk 'BEGIN{FS=" ";}{if( a[$1] ){a[$1]=a[$1]+$2;}else{a[$1]=$2;}}END{for ( i in a ){print i" "a[i];}}'  your_input_file


Cheers,
RangaSmilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Summing the columns of a file

Hi All, I have a file like - num.txt 12, 34, 65, line1 34, 65, 89, line2 43, 65, 77, line3 I want to do two things - 1. Add first three columns of each line and print the line with largest value. i.e. (12+34+65) for 1st line and so on. 2. Add middle column of each line i.e.... (3 Replies)
Discussion started by: asahlot
3 Replies

2. Shell Programming and Scripting

summing values of a column

I have a file which contains data as below: ----------------------------------------------------------------------------------------------- GSPWeb Statistics for the period of last 20 days... (3 Replies)
Discussion started by: mohsin.quazi
3 Replies

3. Shell Programming and Scripting

summing up iostat values in AIX

Friends, I have to run iostat -d on my AIX machine and print the sum of the output in tps column per iteration. can any one pls guide me how to do this using awk. here is the sample output iostat -d 2 2 | awk '!/System/ && !/Disks/ && !/cd/ && !/^$/ {print $4}' 2.0 3.0 1.0 3.0... (1 Reply)
Discussion started by: achak01
1 Replies

4. Shell Programming and Scripting

Awk: Summing values with group criteria

Hi Guys, I have a text file with ";" like separator F1;F2;F3;F4;F5 444;100041;IT;GLOB;1800000000 444;100041;TM;GLOB;1000000000 444;10300264;IT;GLOB;2000000000 444;10300264;IT;GLOB;2500000000 I have to sum the cullums F5 for same F2 and F3 collums The result must be: ... (7 Replies)
Discussion started by: gianluca2
7 Replies

5. Shell Programming and Scripting

reading a script and summing some values

I need help reading and summing some values in a file that looks like the following. This is an Oracle trace file. Oracle has as utility to do this,but it doesn't work properly unless my sql statement is done. I want to read the file and sum up some values to let me know how the query/job is... (0 Replies)
Discussion started by: guessingo
0 Replies

6. Homework & Coursework Questions

HELP with Unix scripts in summing columns in a file.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hi guys, i'm a new guy here, and it's my first time creating a unix script. can you guys help me out here? i'd... (3 Replies)
Discussion started by: ramneim
3 Replies

7. Homework & Coursework Questions

HELP with Unix scripts in summing columns in a file

1. The problem statement, all variables and given/known data: Hi guys, i'm a new guy here, and it's my first time creating a unix script. can you guys help me out here? i'd really appreciate it. :( Here's my problem: This is the file i'm using, it has 6 columns, the first three columns are... (12 Replies)
Discussion started by: ramneim
12 Replies

8. Shell Programming and Scripting

Summing columns in line

I have a file with the following format AAAAA 1.34B 0.76B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.90B 0.00B 0.00B 0.46B 0.00B 0.03B 0.00B ... (4 Replies)
Discussion started by: ncwxpanther
4 Replies

9. Shell Programming and Scripting

Summing columns over group of lines

I have an input file that looks like: ID1 V1 ID2 V2 P1 P2 P3 P4 ..... n no. of columns 1 1 1 1 1.0000 1.0000 1.0000 1.0000 1 1 1 2 0.9999 0.8888 0.7777 0.6666 1 2 1 1 0.8888 0.7777 0.6666 0.5555 1 2 1 2 0.7777 0.6666 0.5555 0.4444 2 1 1 1 0.6666 0.5555 0.4444 0.3333 2 1 1 2 0.5555 0.4444... (4 Replies)
Discussion started by: sdp
4 Replies

10. Shell Programming and Scripting

Summing up values of rows of numbers

data file contains failed=24 error=23 error=163 failed=36 error=903 i need to get a total count of each value above. i'm looking for the most efficient method to do this as the datafile i provided is just a sample. the actual data can be several hundred thousands of lines. so from... (3 Replies)
Discussion started by: SkySmart
3 Replies
UNSHADOW(8)						      System Manager's Manual						       UNSHADOW(8)

NAME
unshadow - combines passwd and shadow files SYNOPSIS
unshadow password-file shadow-file DESCRIPTION
This manual page documents briefly the unshadow command, which is part of the john package. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. john, better known as John the Ripper, is a tool to find weak passwords of users in a server. The unshadow tool combines the passwd and shadow files so John can use them. You might need this since if you only used your shadow file, the GECOS information wouldn't be used by the "single crack" mode, and also you wouldn't be able to use the '-shells' option. On a normal system you'll need to run unshadow as root to be able to read the shadow file. SEE ALSO
john(8), mailer(8), unafs(8), unique(8). The programs are documented fully by John's documentation, which should be available in /usr/share/doc/john or other location, depending on your system. AUTHOR
This manual page was written by Jordi Mallach <jordi@debian.org>, for the Debian GNU/Linux system (but may be used by others). John the Ripper and mailer were written by Solar Designer <solar@openwall.com>. The complete list of contributors can be found in the CRED- ITS file in the documentation directory. john June 03, 2004 UNSHADOW(8)
All times are GMT -4. The time now is 12:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy