I want my script to get the updated lines from a file to another file for each time the script runs.
EX: file1 will be updated time to time(no particular interval can determined, it can update at any time). In my script i want to run a command so that everytime the script runs, it should get the updated lines to a tmp file. If there are no updates, no tmp file should be created.
VARIABLE=`cat tempfile|wc -l`
if [ "$VARIABLE" -eq 0 ]
then
echo "No changes"
rm -F tempfile
fi
cat tempfile
rm -F Newfile
___________________________________________________
I am new to UNIX programming but i thiknk this should work.
Thanks for the replies. @anchal: The code gets the diff of lines(say n lines) but tail will not print all the n lines but it will print the nth line. Rest of the things are good and i am working on this.
@sam: Many thanks for the reply. I feel some editing work needs to be done after the diff command. However, i will try to implement this too.
Cheers,
Sai
---------- Post updated at 08:43 AM ---------- Previous update was at 07:07 AM ----------
Hi anchal...
I have modified your code and tried to get through this - by the end of script i will be with a file which contains only modified lines.
From the above code, for the each run of the script there will be a file(tmpfile1 in script) with ONLY latest updates.
I'd be happy to receive some more ideas regarding this, which would make my task more easier and perfect.