Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

How to compare the current result with previous line result.?

$
0
0
Hi Gurus,
I have requirement to compare current result with previous reuslt.
The sample case is below.
Code:


1  job1    1
1  job2    2
1  job3    3
2  job_a1  1
2  job_a2  2
2  job_a3  3
3  job_b1  1
3  job_b2  2

for above sample file, GID is group ID, for input line, the job run same function and get result.
for same group, I have to compare current job result the previous jobs result (just one line back).
my curernt scrip logic like below:
Code:


 
while loop
do
if order=1 (group 1) then
job1_result> temp_gid1.txt
if order <>1 then
job2_result compare temp_gid1.txt and log to output file
job2_result> temp_gid1.txt
job3_result compare temp_gid1.txt and log to output file
 
if order=1 (new group) then
job1_result> temp_gid2.txt
if order <>1 then
job2_result compare temp_gid1.txt and log to output file
job2_result> temp_gid2.txt
job3_result compare temp_gid1.txt and log to output file

above logic works, but it looks very stupid. I want to put the result in ARRAY then compare the current result with ARRAR, but I am not able to figure our how to compare the current result with previous ARRAY.
another problem I have is: I don't know how to use GID to identify the group changing. so I added column ORDER to identified the new group.

Could anybody give me some help.

thanks in advance.

Viewing all articles
Browse latest Browse all 16232

Trending Articles