hell & mathematics


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting hell & mathematics
# 1  
Old 05-26-2008
hell & mathematics

I've been able to generate output based on the code scarfake provided me (thanks again man).

A little background so everyone more or less knows whats going on:

I needed code that would propagate a database with 100,000 entries, for capacity testing purposes, something like a stress test.

Now I have the results based on timestamps. The timestamps are shown as [1211425845].

[22445] [1211425845](1Jz1CX-0007Qa-7X) MINE::EXIMDB::SF::wblist_check BEGIN
[22445] [1211425846](1Jz1CX-0007Qa-7X) MINE::EXIMDB::SF::wblist_check END

I was told these timestamps are in seconds. Which means the above output equates to a 1 second interval from beginning (BEGIN) to end (END).

If anyone can provide code that would do the math showing how many second(s) intervals per BEGIN and END.

My grep command might help:

grep "BEGIN\|END" /mine/output.log

Thanks for looking Smilie
# 2  
Old 05-26-2008
Is your expected output is something like this ?

Code:
$  sed -n '/BEGIN\|END/ s_\[\(.*\)\].*\[\(.*\)\].*_\2_p' og.txt
1211425845
1211425846

//Jadu
# 3  
Old 05-26-2008
Quote:
Originally Posted by ogoy
If anyone can provide code that would do the math showing how many second(s) intervals per BEGIN and END.
Code:
awk '$NF=="BEGIN"{a=substr($0,10,10)}$NF=="END"{print substr($0,10,10)-a}' data.file


Last edited by danmero; 05-26-2008 at 10:41 PM.. Reason: get shorther
# 4  
Old 05-26-2008
Jaduks, yes that is the expected output.

danmero, that code did it, strange now that I see 0's in the results, goes to show that we need to put more stress into the tests!

Thanks guys SmilieSmilieSmilie
# 5  
Old 05-26-2008
Quote:
Originally Posted by ogoy
, strange now that I see 0's in the results, goes to show that we need to put more stress into the tests!
Add nanoseconds to timestamps for precision.
# 6  
Old 05-26-2008
Thanks for the tip, I'll look into that.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. What is on Your Mind?

Forum Trivial Pursuit - New Computer Science and Mathematics Trivia for UNIX.com

I have added a new experimental "Computer Science and Mathematics Trivia - True or False" section in the discussions, currently under the tags box. In the future, I plan to Expand this feature to add more trivia categories from math, science and technology. Keep track of correct and... (20 Replies)
Discussion started by: Neo
20 Replies

2. Shell Programming and Scripting

quoting hell - help needed!!

I am writing a bash script to automate the installation of web environment on a base install of Fedora. And I'm at the limit of my last nerve and my bash skills. My brain is screaming at me: "Give up and use perl", but I am trying to stick to bash since the script will modify the perl environment... (6 Replies)
Discussion started by: lbe
6 Replies

3. Shell Programming and Scripting

Which is the best way/command to do mathematics in UNIX scripting?

Hello all! I used to use expr for doing simple mathematics, but has a main advantage and a main disadvantage: The advantage is that it can take variables for numbers (e.g.{1}: echo "Give me first" read lol echo "Give other" read lil sum=`expr $lol + $lil` echo "The sum of $lol and $lil =... (5 Replies)
Discussion started by: hakermania
5 Replies

4. UNIX for Dummies Questions & Answers

Confussed as hell

:eek: (1 Reply)
Discussion started by: Kevinfine
1 Replies

5. Shell Programming and Scripting

hell and sqlite

Hi everyone, I have a requirement that requires me to fill an sqlite database with 100,000 entries (no duplicates). I will start out by giving the command that will insert the values necessary to populate the database: # sqlite /var/local/database/dblist "insert into list... (2 Replies)
Discussion started by: ogoy
2 Replies

6. UNIX for Dummies Questions & Answers

rpm hell!

I've just installed redhat 6.2 on one of my systems and am trying to install the gcc c compiler after downloading an rpm from the redhat site. The damn thing gives me: only major numbers <= 3 are supported by this version of RPM what do I do, it does the same with the latest rpm of php ... (7 Replies)
Discussion started by: knmwt15000
7 Replies

7. UNIX for Dummies Questions & Answers

mathematics in shell script

Hi Friends, I am new to shell scripting and a trying to work this out. I have a variable called $number. The value in this variable is 10 I want to display $number - 2 in a mail. The result would be 8 eg. mail -s 'subject' user <<eof the result of your calculation is $number - 2... (2 Replies)
Discussion started by: sureshy
2 Replies

8. UNIX for Dummies Questions & Answers

mathematics operations in unix

Hello guys! Can say me anybody about operatios with unix, I don't to make operations, only inside in a variable, like this #y=4 #x=2 #let z=$y-$x #echo $z # 2 but I can't to make mathematical operations with decimal like this #y=3.2 #x=1.5 #let z=$y-$x #echo $z # 3 this... (2 Replies)
Discussion started by: cesar720213
2 Replies
Login or Register to Ask a Question