Need help in finding sum for values in 2 different fields
Hi there,
I have 2 files in following format
cat file_1
cat file_2
In file_1 I have host name aaaa,bbbb,cccc,dddd etc... below them i have some values assigned to that host name below UID
eg: aaaa has 21 and bbbb has 9 ,cccc has 1001, dddd has 143,429 , ffff has 4290,4292,4293,4294,4291,4295 etc.....
file_2 has values assigned to them first column values are the onces which should be used as reference i.e for aaaa-> 21 in file_2 next to 21 we have 935 for some hosts we have many values.
i.e 0-- 11
This is what I want from the two files.
I want to get the host name and get the sum of values from file_2
my final o/p should be in the following format.
etccc
Please let me know if I am not clear. Thanks in advance.
I'm trying to sum each field of the second column over many different files.
For example:
file1: file2:
1 5 1 5
2 6 2 4
3 5 3 3
To get:
file3
1 10
2 10
3 8
I found answer when there are only 2 files as... (10 Replies)
Hi all,
I have following scenario to perform sum aggregation on certain columns
Node Allocated_Space Pool_Name CS_Group Utilized Space
-------- ---------------- ---------- --------- --------------
bdw1a_lun01 300 bdw_p0 ... (2 Replies)
Hello friends,
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:
2nd 3rd 12th
123 05.11.2010 09:27 0
124 05.11.2010 09:28 0
125 05.11.2010 09:34 1
126 05.11.2010 09:39 0... (5 Replies)
I am running the following script :
cat ind_sls_extr_UX.out_sorted | while read each_rec
do
count=`echo "${each_rec}" | cut -c1-2`
if
then
final_amount=0
amount=`echo "${each_rec}" | cut -c280-287`
echo "${amount}"
final_amount=`expr ${amount} + ${amount}`
... (7 Replies)
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 am trying to add count values from two different files into one file. Could any body please suggest me best command to do this? My problem was as follows:
a.txt b.txt c.txt
10 20 30(needed)
i tried cat a.txt b.txt > c.txt (its not adding the values)
Thanks in advance..
Praveen (8 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)
Hey,
I have a file and it has only one field. I need to calculate the sum of each filed as total.
For e.g my file is
1
2
3
4
5
I need to calculate the total sum as 15.
Please let me know how i can do it? (4 Replies)
HI ALL,
i have a problem when i do a sort sum with many fields.
Is there a limit for fields?
Do you know a solution?
thanks in advance.
the shell is:
# SORT1
SORT1_rcode=777
if ; then
echo "USE $DARSEQ/OTPU.FTPEPREC RECORD F,1000 " > $DARPARSRT/TPEKL508.SORT1_$$.srt
... (6 Replies)