I have a database export and with this export i need to find some statistics which is required. I take the export of a table with only 3 columns like this:
Only the 2nd and 12th columns are important; 2nd column is subscribers and 12th is media result. If a subscriber listens media before their call connected then their media result is 1 otherwise 0. How could i find sum of subscribers who has listened the media (media result =1) in their first calls or second calls etc?
Output :
3rd column of Subscribers 125 and 127 are "1" in first times so sum of them in 1st times is 2..
Is associative arrays of awk the right method here? As an average awk user im not good at in associative arrays, I need your help i couldnt find a similar thread and nothing else comes into my mind..
Regards
Last edited by EAGL€; 11-07-2010 at 07:13 AM..
Reason: adding info..
Hi,
I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern.
Note:These are the samples of two files,but i can have more... (2 Replies)
Hi
I have an file which looks like
country address phone amount
sweden |address |phone | 10 |
Singapo |address |phone | 20 |
Italy-N |address |phone | 30 |
denmar |address |phone | 40 |
Here i need to do the sum(amount), how to do this in shell scripting
Thanks
Babu (11 Replies)
Hello everyone I need to write a script that sums numbers passed to it as arguments on the command line and displays the results. I must use a for loop and then rewrite it using a while loop. It would have to output something like 10+20+30=60
this is what I have so far
fafountain@hfc:~$ vi sum... (1 Reply)
cat *.out |grep "<some text>" | awk '{print $6}'
For ex,This will reutrn me
11111
22222
is it possible to add these two numbers in the above given command itself?I can write this to a file and find the sum.
But I prefer to this calculation in the above given line itself.
Any... (3 Replies)
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)
Hi
I need to incorporate a 'sum' as follows into a script and not sure how. I have a variable per line and I need them to be summed, e.g below
1
23
1,456
1
1
34
46
How do I calculate the sum of all these numbers to ouptut the answer ( 1,562)
Thanks in advance (3 Replies)
I am trying to get the sum of the first column of a file. When I use the same method for other files it works just fine... for some reason for the file below it gives me an error that I don't understand... I tried looking at different lines of the file and tried different things, but I still... (7 Replies)
Hi, Unix Gurus,
I need sum values from a file. file format like:
0004004
0000817
0045000
0045000
0045000
0045000
0045000
0045000
0045000
0045000
0045000
0045000
0004406
the result should be 459227 (817+45000 ... + 4406)
anybody can help me out (7 Replies)
Hi there,
I have 2 files in following format
cat file_1
Storage Group Name: aaaa
HBA UID SP Name SPPort
------- ------- ------
0 21
Storage Group Name: bbbb
HBA UID... (2 Replies)
hi Gurus,
I have an extract as seen below:
INPUT
2015-08-24 15:00:00.0 |TCSERVER01 |ServiceEventHandler |2283
2015-08-24 15:01:00.0 |TCSERVER01 |ServiceEventHandler |576
2015-08-24 15:02:00.0 |TCSERVER01 |ServiceEventHandler |833
2015-08-24 15:03:00.0 |TCSERVER01 |ServiceEventHandler... (6 Replies)
Discussion started by: reignangel2003
6 Replies
LEARN ABOUT POSIX
export
EXPORT(P) POSIX Programmer's Manual EXPORT(P)
NAME
export - set the export attribute for variables
SYNOPSIS
export name[=word]...
export -p
DESCRIPTION
The shell shall give the export attribute to the variables corresponding to the specified names, which shall cause them to be in the envi-
ronment of subsequently executed commands. If the name of a variable is followed by = word, then the value of that variable shall be set to
word.
The export special built-in shall support the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
When -p is specified, export shall write to the standard output the names and values of all exported variables, in the following format:
"export %s=%s
", <name>, <value>
if name is set, and:
"export %s
", <name>
if name is unset.
The shell shall format the output, including the proper use of quoting, so that it is suitable for reinput to the shell as commands that
achieve the same exporting results, except:
1. Read-only variables with values cannot be reset.
2. Variables that were unset at the time they were output need not be reset to the unset state if a value is assigned to the variable
between the time the state was saved and the time at which the saved output is reinput to the shell.
When no arguments are given, the results are unspecified.
OPTIONS
See the DESCRIPTION.
OPERANDS
See the DESCRIPTION.
STDIN
Not used.
INPUT FILES
None.
ENVIRONMENT VARIABLES
None.
ASYNCHRONOUS EVENTS
Default.
STDOUT
See the DESCRIPTION.
STDERR
The standard error shall be used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
Zero.
CONSEQUENCES OF ERRORS
Default.
The following sections are informative.
APPLICATION USAGE
None.
EXAMPLES
Export PWD and HOME variables:
export PWD HOME
Set and export the PATH variable:
export PATH=/local/bin:$PATH
Save and restore all exported variables:
export -p > temp-fileunset a lot of variables... processing. temp-file
RATIONALE
Some historical shells use the no-argument case as the functional equivalent of what is required here with -p. This feature was left
unspecified because it is not historical practice in all shells, and some scripts may rely on the now-unspecified results on their imple-
mentations. Attempts to specify the -p output as the default case were unsuccessful in achieving consensus. The -p option was added to
allow portable access to the values that can be saved and then later restored using; for example, a dot script.
FUTURE DIRECTIONS
None.
SEE ALSO
Special Built-In Utilities
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol-
ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. 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 Standard is the referee document. The original Standard can be obtained
online at http://www.opengroup.org/unix/online.html .
IEEE /The Open Group 2003 EXPORT(P)