adding


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers adding
# 1  
Old 11-07-2008
adding

Hi All
i need a add recored like
DateOfDU2=245,Time=00326 (in milli secounds )
DateOfDU2=245,Time=00347
DateOfDU2=245,Time=00258
DateOfDU2=246,Time=00325
DateOfDU2=246,Time=00408
DateOfDU2=246,Time=00257
DateOfDU2=247,Time=00037
DateOfDU2=247,Time=00417
DateOfDU2=247,Time=00420
DateOfDU2=245,Time=00314
DateOfDU2=248,Time=00304
DateOfDU2=248,Time=00249
DateOfDU2=248,Time=00430
DateOfDU2=249,Time=00459
DateOfDU2=249,Time=00418

answer should be
245 -97
246 - 99
247 -88
248 -108
249 - 88

Thanks


# 2  
Old 11-07-2008
Not sure about the calculation (you may need to adjust keys[k]/10):
(use nawk or /usr/xpg4/bin/awk on Solaris)

Code:
awk -F'[=, ]' 'END {
  for (k in keys) print k, keys[k]/10
  }
{ keys[$2] += $4 }' OFS=' - ' infile


Last edited by radoulov; 11-07-2008 at 10:11 AM.. Reason: adjust OFS
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies

2. UNIX for Dummies Questions & Answers

Adding

my shell script: #!/bin/ksh date +%d > /tmp/day.log day=`tail /tmp/day.log` ############################ for example: date +%d shows me 05 i want to add 14 days to 05 into my above script. bc 5+15 19 but i am not sure how to put into above script. (5 Replies)
Discussion started by: lawsongeek
5 Replies

3. UNIX for Dummies Questions & Answers

adding whitespace

Hi guys, I am working with large data sets and often times realize that not all of the columns are aligned correctly (sometimes rows will be shifted). So when I try to do something like: awk '{ if ($2 > 30 && $5 == $3){print}}' file > output it won't really work since some of the rows... (2 Replies)
Discussion started by: verse123
2 Replies

4. AIX

adding new ip

Hi Admins, I was told to add new ip,mask and gateway to my 3rd nic.so i prepared a plan doing the same via smitty. now i need to know do i plumb and unplumb before adding ip. plz suggest Regards newaix (1 Reply)
Discussion started by: newaix
1 Replies

5. Shell Programming and Scripting

Adding numbers

Hi I figured how to add my list of numbers. However how do I count so that after a certain number it lists the line. Example: 12 test1 46 test2 195 test3 174 test4 634 test5 185 test6 94 test7 So basically add the numbers and when the addition reaches 300 or less print the... (8 Replies)
Discussion started by: bombcan
8 Replies

6. Shell Programming and Scripting

Adding new field

Hello, I have a main file with IP addresses like this: Erisim var,100,172.17.241.5,4006,60,IS0799,TCP/IP Erisim var,1003,172.17.140.4,4004,60,IS2156,TCP/IP Erisim var,1004,172.17.140.5,4002,60,IS2636,TCP/IP Erisim var,1005,172.17.140.5,4004,60,IS2436,TCP/IP Erisim... (8 Replies)
Discussion started by: Spunkerspawn
8 Replies

7. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

8. UNIX for Advanced & Expert Users

adding zero's

Hi I am comparing two files, 100th column have formatting issue i mean 1 file have scale 4 and anothe file scale 2 ,if scale 2 need to add two zeros.Please any idea how to add two zers to 100th coulmn if scale is 2 file 1 .................1234.2000 file2 ................1234.20 ... (3 Replies)
Discussion started by: mohan705
3 Replies

9. Shell Programming and Scripting

adding 0 to a variable

Can anybody plz help me to solve this puzzle? amt=00002280674231 ((amt = amt + 0)) # to remove leading zero's echo $amt prints -2014293065 but this works fine for numbers less than 2000000000. Thanks S (3 Replies)
Discussion started by: shivakundan
3 Replies

10. Solaris

Adding new groups!!

I want to know how we can add a new group in solaris. As per my understanding this is done by adding a new entry in /etc/groups file (or by using groupadd command which will also add the entry in the groups file). But when I use group command to see the groups to which I belong, it shows my userid... (7 Replies)
Discussion started by: atheek
7 Replies
Login or Register to Ask a Question