Dynamic Attribute Changes

Hello ,

I am stuck out in a part of my script, though I am trying it through a script of loops but i emphasis on having a short code :

Input file has Attribute values changing with time

Date Monday October 30 10:22:56 IST 2006
object values references Date
Priya 157676 101 Oct 18 14:34
Ananya 157677 102 Oct 18 14:34
Rahul 157678 103 Oct 18 14:34
Neha 157679 104 Oct 18 14:34
Mrinal 157680 105 Oct 18 14:34
Pakash 157681 106 Oct 18 14:34
Chhavi 157682 107 Oct 18 14:34
Rita 157683 108 Oct 18 14:34
Tina 157684 109 Oct 18 14:34
Waqir 157685 109 Oct 18 14:34
Date Monday October 30 10:23:56 IST 2006
object values references Date
Priya 145020 101 Oct 18 14:34
Ananya 157677 102 Oct 18 14:34
Rahul 157678 103 Oct 18 14:34
Neha 157679 104 Oct 18 20:55
Mrinal 157680 105 Oct 18 14:34
Pakash 157681 124 Oct 18 14:34
Chhavi1 157682 107 Oct 18 14:34
Rita 157683 108 Oct 20 14:34
Tina 157684 109 Oct 18 14:34
Waqir 157685 109 Oct 18 14:34
Date Monday October 30 10:24:56 IST 2006
object values references Date
Priya 145687 101 Oct 18 14:34
Ananya 157677 102 Oct 11 14:34
Rahul 157678 104 Oct 18 14:34
Neha 157679 104 Oct 18 20:55
Mrinal 157680 105 Oct 18 14:34
Pakash 157681 106 Oct 18 14:34
Chhavi 157682 107 Oct 18 14:34
Rita 157683 108 Oct 18 14:34
Tina 157684 109 Oct 18 14:34
Waqir 157685 109 Oct 18 14:34

The Objects Changes the value/Refernces and date within a min
Thus the output file should conatins the list of objects whose parameters has changed

Output file
Date/Time Object Values Refernces Date
October 30 10:22:56 Priya 157676 101 Oct 18 14:34
October 30 10:23:56 Priya 145020 101 Oct 18 14:34
October 30 10:24:56 Priya 145687 101 Oct 18 14:34
October 30 10:22:56 Pakash 157681 106 Oct 18 14:34
October 30 10:23:56 Pakash 157681 124 Oct 18 14:34
October 30 10:24:56 Pakash 157681 106 Oct 18 14:34
October 30 10:22:56 Chhavi 157682 107 Oct 18 14:34
October 30 10:23:56 Chhavi1 157682 107 Oct 18 14:34
October 30 10:24:56 Chhavi 157682 107 Oct 18 14:34

Output file signifies that any change in object parameters should list what was the past object parameters, changed parameters and
new parameters after change .

I beleive its a really challenging taks which I am trying to sort out from past few days...
It would be really great if anyone could help me in This

KRegards,
Aparna

Steps to be done.
------------------

1). First get the list of all the values for ex

Priya , Prakash etc into a file.

using

cat file_name | cut -d ' ' -f4-4 | sort -u > temp_file.

2). Then read each value using loop and grep and print the values in the order you want.

for i in `cat temp_file`
do
grep -i $i "from_file" > result_file.
done

I guess this way your problem can be solved.

Hello ,
Thanks for the reply . but the problem is not solved with this because what this crsipt will do is just grep the object and paste in the output file
However what i want is whenever there is any change in the parameters value then only it should print the output in the output file

Suggestions are still awaited

KRegards,
Aparna

once you collect all these values into a file.

You can use AWK
to compare the values on the reqd column
and if the new value of date != old value of date then
you can print the old value else ignore.

That is what is my point of concern!!!Awk doesnt takes variables values and comparison cannt be performed with varaible as number of times the sequence is repeated is unknown .... the parameters may be repeated after n sec for total m hrs ....

KRgs
Aps

I think , this is what you are looking for

first, you have to copy i/p info to the file as file_name

grep -v "Date" file_name | grep -v "IST" | sort -u

you can use following command to compare variable for "awk" command

#!/bin/sh
#assign shell's $1 ti awk search variable

search=$1
awk '$1 ~ /'"$search"'/' acronyms

cheers

Hello ,

Though i will b to pass the variable through this awk statement by question lies otherways how will i compare each parameter value for each existnace that is still unknown to me!!

Pls suggest

Aparna

Not sure I understand the requirement fully, perhaps you can adapt this...

awk '
  $1 == "Date" {
     d = $3 " " $4 " " $5
     next
  }
  $1 == "object" {
     next
  }
  {
    print d, $0
  }
  ' file1 | sort -u -k4,5

...which gives...

October 30 10:22:56 Ananya 157677 102 Oct 18 14:34
October 30 10:22:56 Chhavi 157682 107 Oct 18 14:34
October 30 10:23:56 Chhavi1 157682 107 Oct 18 14:34
October 30 10:22:56 Mrinal 157680 105 Oct 18 14:34
October 30 10:22:56 Neha 157679 104 Oct 18 14:34
October 30 10:22:56 Pakash 157681 106 Oct 18 14:34
October 30 10:23:56 Priya 145020 101 Oct 18 14:34
October 30 10:24:56 Priya 145687 101 Oct 18 14:34
October 30 10:22:56 Priya 157676 101 Oct 18 14:34
October 30 10:22:56 Rahul 157678 103 Oct 18 14:34
October 30 10:22:56 Rita 157683 108 Oct 18 14:34
October 30 10:22:56 Tina 157684 109 Oct 18 14:34
October 30 10:22:56 Waqir 157685 109 Oct 18 14:34

Hello ,

Thanks for yr suggestion it z helping me but not fully the output which i want should have the entries where there is any change in any value ie as below
Desired o/p :
Date/Time Object Values Refernces Date
October 30 10:22:56 Priya 157676 101 Oct 18 14:34
October 30 10:23:56 Priya 145020 101 Oct 18 14:34
October 30 10:24:56 Priya 145687 101 Oct 18 14:34
October 30 10:22:56 Pakash 157681 106 Oct 18 14:34
October 30 10:23:56 Pakash 157681 124 Oct 18 14:34
October 30 10:24:56 Pakash 157681 106 Oct 18 14:34
October 30 10:22:56 Chhavi 157682 107 Oct 18 14:34
October 30 10:23:56 Chhavi1 157682 107 Oct 18 14:34
October 30 10:24:56 Chhavi 157682 107 Oct 18 14:34

Where priya had reference as 157676 at 10:22:56 but changed to 145020 at
10:23:56 and 145687 at 10:24:56 .
similarly for Pakash and Chhavi . However ,
there exists no other entry for ANY OBJECT whose ANY parameter has not changed.

I hope now the things are clear . unix forum has always given me desired answer of my queries hoping for the same

KRgs
Aparna