11-30-2010
Bakunin,
first off , I would like to thank you ,,your post was more than helpful .
Quote:
Another point is: Might there be lines which don't need processing? Lets consider the following:
I think I missed this point , I'll do something about it.
Quote:
Still, there is a more subtle point I'd like to raise - one, which isn't explicitly covered by your requirement, but is best learned from the very beginning of ones programming career: If you get user input you should validate it!
Yes , I know its an important point , and I'am going to make sure to add this to my script, it just about that my problem was in awk , now I understand what to do .
Thanks again.
RGD
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi
I want to sum of 3 columns in file.
Example: I want to sum of 3 ,6,8 th columns in file(SUM(3,6,8)).
Using awk can sum of single column
awk '{a+=$3} END {printf ("%f\n",a)' file_name
Thanks inadvance
MR (2 Replies)
Discussion started by: mohan705
2 Replies
2. Shell Programming and Scripting
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)
Discussion started by: Blinky85
1 Replies
3. Shell Programming and Scripting
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
4. Solaris
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)
Discussion started by: rob171171
3 Replies
5. UNIX for Dummies Questions & Answers
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)
Discussion started by: cosmologist
7 Replies
6. Shell Programming and Scripting
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)
Discussion started by: ken002
7 Replies
7. Shell Programming and Scripting
I have a list of values ( in Kb) I have the following code to sum up the values and convert the total to GB
cat list
701368101370
101370101370
801554101370
701636101370
101757101370
101876101370
901951101370
And this is the output of my script
awk '{ s += $1 } END {... (3 Replies)
Discussion started by: Sara_84
3 Replies
8. Shell Programming and Scripting
Hi Friends,
I have a file with fields separated with comma. How to print sum of each field of the file?
Eg:
input file
1,3,6,7
2,1,2,1
0,1,1,0
I want to sum each field separately.
Output file
3,5,9,8
Thanks,
Suresh (2 Replies)
Discussion started by: suresh3566
2 Replies
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
HI Guys,
I gave Input file F.Txt
ID H1 H2 H3 H4 H5
A 5 6 7 8 9
B 4 65 4 4 7
C 4 4 4 4 4
D 4 4 4 4 4
Output :-
ID H1 H2 H3 H4 H5
Total 17 79 19 20 24
Sum of Each Columns (8 Replies)
Discussion started by: pareshkp
8 Replies
LEARN ABOUT CENTOS
platform::shell
platform::shell(n) Tcl Bundled Packages platform::shell(n)
__________________________________________________________________________________________________________________________________________________
NAME
platform::shell - System identification support code and utilities
SYNOPSIS
package require platform::shell ?1.1.4?
platform::shell::generic shell
platform::shell::identify shell
platform::shell::platform shell
_________________________________________________________________
DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell.
This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only
requirement is that the other shell (identified by its path), is actually executable on the current machine.
While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell
this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run
32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers.
For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed
packages, versus the architecture of the shell running the repository software.
COMMANDS
platform::shell::identify shell
This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell.
platform::shell::generic shell
This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell.
platform::shell::platform shell
This command returns the contents of tcl_platform(platform) for the specified Tcl shell.
KEYWORDS
operating system, cpu architecture, platform, architecture
platform::shell 1.1.4 platform::shell(n)