File delta detection


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File delta detection
# 8  
Old 08-11-2012
OK, based on the input and the desired result you have posted, this might do. Give it a try:
Code:
awk 'BEGIN {FS="|";OFS=FS;fmt="%s%s"; aOK=bOK=needa=needb=1}

        function prt (X) {for (i=1;i<=7;i++) printf fmt, X[i],OFS; print appch}

        {
         while (aOK || bOK)
                {if (needa) aOK=getline a<filea;
                 if (needb) bOK=getline b<fileb;
                 if (!(aOK||bOK)) exit;
                 if (a==b)                              {needa=1; needb=1; next};

                 if (aOK) {split(a,ai)} else {ai[3]=ai[5]="z"};
                 if (bOK) {split(b,bi)} else {bi[3]=bi[5]="z"};

                 if(ai[3]ai[5]==bi[3]bi[5])             {needa=1; needb=1; appch="u"}
                 else   if(ai[3]ai[5]>bi[3]bi[5])       {needa=0; needb=1; appch="d"}
                        else                            {needa=1; needb=0; appch="i"}

                 if (appch=="d") {prt(bi)} else {prt(ai)};
                }
         exit
        }
        ' filea=new fileb=old new

resulting in
Code:
b|dm|2|bp|20|$lwa!|sdf|u
c|co|3|mb|30|&dhf!|gfh|d
d|te|4|value|40|@kdk-|kdd|u
f|sv|5|jdjd|50|^ghd2|uyy|i

which is pretty close to what you requested. Pls. test thoroughly and come back with results.

Last edited by RudiC; 08-12-2012 at 01:43 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delta from the first digit

Thanks of your suggestions i was able to calculate the delta between some numbers in a column file with . awk 'BEGIN{last=0}{delta=$1-last; last=$1; print $0" "delta}' the file was like 499849120.00 500201312.00 500352416.00 500402784.00 500150944.00 499849120.00 500150944.00... (3 Replies)
Discussion started by: Board27
3 Replies

2. Shell Programming and Scripting

GPS extracts fix delta time

Hello all, I am currently trying to find the delta time from some GPS log. I am using the following script with awk. But the script result shows some incorrect values (delta time some time = 0.2 but when I check it manually it is equal to 0.1) My final goal is to get a script that print... (7 Replies)
Discussion started by: redafenj
7 Replies

3. Shell Programming and Scripting

Comparing delta values of one xml file in other xml file

Hi All, I have two xml files. One is having below input <NameValuePair> <name>Daemon</name> <value>tcp:7474</value> </NameValuePair> <NameValuePair> <name>Network</name> <value></value> </NameValuePair> ... (2 Replies)
Discussion started by: sharsour
2 Replies

4. Shell Programming and Scripting

help with email to be triggered based on fatal error detection from batch run log file neded

Hi, I require need help in two aspects actually: 1) Fatal error that gets generated as %F% from a log file say ABClog.dat to trigger a mail. At present I manually grep the log file as <grep %F% ABClog.dat| cut-d "%" -f1>. The idea is to use this same logic to grep the log file which is... (1 Reply)
Discussion started by: zico1986
1 Replies

5. Programming

Parallel Processing Detection and Program Return Value Detection

Hey, for the purpose of a research project I need to know if a specific type of parallel processing is being utilized by any user-run programs. Is there a way to detect whether a program either returns a value to another program at the end of execution, or just utilizes any form of parallel... (4 Replies)
Discussion started by: azar.zorn
4 Replies

6. Shell Programming and Scripting

Creating DELTA file in UNIX

I have a fixed length file (854 characters file). Our project will start getting this file soon. On the first day this file will have 100000 records. From the next day the file will have all the records from previous day + some new records (there will be few additions + few changes in day1... (13 Replies)
Discussion started by: varunrbs
13 Replies

7. Shell Programming and Scripting

File detection then run script

I am currently running 4 scripts to complete a job for me. Each script requires the finished file of the one before it. For example the first script gets the finished file called model.x, then i would like script2 to start in and use model.x as the input and get model_min.x as the finished... (5 Replies)
Discussion started by: olifu02
5 Replies
Login or Register to Ask a Question