Sponsored Content
Full Discussion: Dealing with sum
Top Forums UNIX for Dummies Questions & Answers Dealing with sum Post 302844049 by radius on Friday 16th of August 2013 08:22:35 AM
Old 08-16-2013
Dealing with sum

I have file input
Code:
1/1/2013    1AS030A    0    1083    CHINA
1/1/2013    1AS030B    0    675        KOREA
1/1/2013    1AS035A    162    662        CHINA
1/1/2013    1AS035B    51    799        INDIA
1/1/2013    1AS035C    0    731        CHINA
1/2/2013    1AS073A    10    1375    KOREA
1/2/2013    1AS073B    0    89        KOREA
1/2/2013    1AS073C    0    159        INDIA
1/2/2013    1AS149A    3    987        CHINA
1/3/2013    1AS149B    97    1324    CHINA
1/3/2013    1AS149C    104    1030    CHINA
1/3/2013    1AS149E    0    826        CHINA
1/3/2013    1AS149F    0    1592    CHINA
1/4/2013    1AS149G    0    1682    KOREA
1/4/2013    1AS151A    0    886        KOREA
1/4/2013    1AS151B    0    969        INDIA
1/4/2013    1AS151C    5    1271    INDIA
1/4/2013    1AS152A    278    1560    KOREA
1/4/2013    1AS152B    0    871        INDIA
1/4/2013    1AS152C    0    887        CHINA

output I expect to have is

Code:
1/1/2013    CHINA    162    2476    6.54%
1/1/2013    INDIA    51    799        6.38%
1/1/2013    KOREA    0    675        0.00%
1/2/2013    CHINA    3    987        0.30%
1/2/2013    INDIA    0    159        0.00%
1/2/2013    KOREA    10    1464    0.68%
1/3/2013    CHINA    201    4772    4.21%
1/4/2013    CHINA    0    887        0.00%
1/4/2013    INDIA    5    3111    0.16%
1/4/2013    KOREA    278    4128    6.73%

sum all column3 when its column5(country) and column1(date) are same and also sum column4, print its percentage

thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in dealing with arra

I am readinga file lin by line and based craeting a arry of unique elemenst from the second column of the line. However when i coem out of the while loop my array becomes empty , can eny one tell me what I would be doing wrong #!/bin/bash logfile="./mylog.dat" begin=100 end="$(( $begin +... (5 Replies)
Discussion started by: jojan
5 Replies

2. Shell Programming and Scripting

Dealing with log files

Hi , My requirement is that i need to search for a number of strings in a log file and print them with line numbers.The search should be date wise. The sample log file is : Jan 17 02:45:34 srim6165 MQSIv500: (UKBRKR1P_B.LZ_ BENCHMARKS)BIP2648E: Message backed out to a queue; node... (6 Replies)
Discussion started by: charudpss
6 Replies

3. UNIX and Linux Applications

webinject - dealing with popups

Hello We have a webapp that launches a link in a popup. We need to use webinject to check the content of that popup but have been so far unsuccessful. We use webinject as a nagios plugin. Does anyone have any experience of using/configuring webinject and know if this is possible or not? ... (1 Reply)
Discussion started by: skewbie
1 Replies

4. Shell Programming and Scripting

Dealing with files with spaces in the name

Hello, I'm a computer science major and I'm having problems dealing with file names with spaces in them. Particularly I'm saving a file name in a variable and then using the variable in a compare function i.e. a='te xt.txt' b='file2.txt' cmp $a $b If anyone could help me with this particular... (10 Replies)
Discussion started by: jakethegreycat
10 Replies

5. Shell Programming and Scripting

Print sum and relative value of the sum

Hi i data looks like this: student 1 Subject1 45 55 Subject2 44 55 Subject3 33 44 // student 2 Subject1 45 55 Subject2 44 55 Subject3 33 44 i would like to sum $2, $3 (marks) and divide each entry in $2 and $3 with their respective sums and print for each student as $4 and... (2 Replies)
Discussion started by: saint2006
2 Replies

6. Shell Programming and Scripting

cp not dealing with variable properly? please help

I am having trouble with a script that is supposed to : a)take all the jpg pictures in a given directory/parameter and create thumbnails of it in a directory on the desktop. e.g from /here/are/the/files.jpg to ~/Desktop/parser-the/files.png this is my script: all the individual parts... (2 Replies)
Discussion started by: orochinagi
2 Replies

7. Programming

Need help with Card Dealing Program

I'm currently making a card dealing program, it is suppose to display a list of cards like this: "Ace of Heart, is red" "Two of Heart, is red" . . "Ace of Spade, is black" and so on for all suits and numbers. here is my current code: #include <stdio.h> #include <stdlib.h> #include... (3 Replies)
Discussion started by: Izzy123
3 Replies

8. UNIX and Linux Applications

Dealing with geany core

Geany : Home Page, the text editor, sometimes crashes and leaves a geany.core file. This is a binary file and supposedly contains all unsaved work and possibly some other information. Does anyone know how to deal with this file? (2 Replies)
Discussion started by: figaro
2 Replies

9. Slackware

Dealing with lilo and uefi

Recently I have been trying to boot into slackware on a new laptop that came preinstalled with windows 8. I have successfully installed slackware and Lilo, but I have had great difficult attempting to boot into it. Since the laptop contains no optical drive, I have been attempting to boot into... (2 Replies)
Discussion started by: a sandwhich
2 Replies

10. Programming

Dealing with XML comments

I'm writing my own simple XML parser as an experiment. It's a lot more complicated than it's supposed to be. Things supposedly forbidden in XML comments happen all the time in the wild. You're never, ever supposed to find -- inside <!-- xml comments --> but in practice, you don't just find... (2 Replies)
Discussion started by: Corona688
2 Replies
SETPWENT(3P)						     POSIX Programmer's Manual						      SETPWENT(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
setpwent -- user database function SYNOPSIS
#include <pwd.h> void setpwent(void); DESCRIPTION
Refer to endpwent(). COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Stan- dard is the referee document. The original Standard can be obtained online at http://www.unix.org/online.html . Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . IEEE
/The Open Group 2013 SETPWENT(3P)
All times are GMT -4. The time now is 04:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy