Hi all,
...
but i need to find out the differnce between the last line $1 value and the second last line value $1
Assuming the lines of interest are of the same format ( as posted ) and they're always present in the last 40 records of the log file, you can do something like this:
As per my understanding of your requirement, the code works as expected.
Quote:
Originally Posted by senthilkumar_ak
...but i need to find out the differnce between the last line $1 value and the second last line value $1
I see that you need to substract the second to the last line value ( in blue ) from the last line value ( in red ), disregarding entirely all the previous records, ( as I see it ).
My conclusions stemmed from your posted code, which points to those colored values ( btw there's a missmatch between your first and second tail in your first post, I used the first ). In absence of a good sample, I provided my own:
( Displaying only the last records )
Code:
$ tail logfile
....
<GC(4140): freed 168190456 bytes, 66% free (180990488/271776256), in 253 ms>
data other data other data
data other data other data
<GC(4141): freed 167436384 bytes, 66% free (180290224/271776256), in 414 ms>
data other data other data
<GC(4142): freed 168588096 bytes, 66% free (181440728/271776256), in 352 ms>
data other data other data
$ tail -40 logfile | awk -F'[(/)]' '/: freed/{ y=x; x=$4 }END{ print "x->" x " y->" y " |difference in MB-> " (x-y)/(1024*1024) }'x->181440728 y->180290224 |difference in MB-> 1.09721
I believe the main issue of extracting the last adjacent values is resolved, so little effort is needed modifying the code.
In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13.
I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Hi Guys,
What is difference between this two lines in script
logger -p daemon.info -t postback Starting /opt/local/bin/backup-report
and
/opt/local/bin/backup-report
is the backu script running twice here?
Thanks, (2 Replies)
I have two files named Before.txt and After.txt:
Now i want to find the difference in content between <Marker 1> and <Marker 2> in the two files.
---------- Post updated at 05:00 PM ---------- Previous update was at 04:50 PM ----------
Any help will be highly appreciated..:) (3 Replies)
Hello
I have a file in following format:
IV 08:09:07
NM 08:12:01
IC 08:12:00
MN 08:14:20
NM 08:14:15
I need a script to compare time on each line with previous line and show the inconsecutive line. Ex.:
08:12:00
08:14:15
A better way... (6 Replies)
13608:End of Tests.
13811:End of Tests.
14014:End of Tests.
14217:End of Tests.
14420:End of Tests.
14623:End of Tests.
14826:End of Tests.
15029:End of Tests.
15232:End of Tests.
15435:End of Tests.
15638:End of Tests.
i have file like above. i want difference betwwn first field of... (2 Replies)
Hi guru's,
Am new to shell scripting.
I am getting the below o/p from the oracle database, when I fire a query.
ID JOB_ID ELAPSED_TIME FROM TO
----- ------ ------------------- -------- --------
62663 11773 01/06/2009 09:49:13 SA CM
62664 11773 ... (4 Replies)
I have two files like this:
#FILE 1
ABCD 4322 26485
JMTJ 5311 97248
XMPJ 4321 58978
#FILE 2
ABCD 4321 26485
JMTJ 5311 97248
XMPJ 4321 68978
What to do: Compare the two files and find those lines that doesn't match. And have a new file like this:
#FILE 3
"from file 1"
ABCD 4322 26485... (11 Replies)
Hi everyone,
i have files containing lines of number:
109
107
67
62
..
..
i want to calculate the difference between numbers in lines 1 and 2, 3 and 4, 5 and 6 and so on. would someone help me please?. Thanks (12 Replies)
I would like my script to be able to tell the difference between to lines of input, like:
Input 1:
1 2 3 4 5
Input 2:
1 2 3 4 5 6
I want the script to tell me that the difference between the two lines is the 6. Is there anyway I can have it do this?
Here's an example of what my script... (12 Replies)