Shell script to find out which properties are modified/added/deleted.
Hi Guys,
I am trying to write a shell script which will tell me which properties are modified/added or deleted. Lets say I have the old property files in a folder /home/anon84/old_props and the new ones in a folder /home/anon84/new_props.The property file names are same in both folders. Sample property in any property file (say test.properties) sample_key_name = sample_key_value I want my script to produce output like this: Properties updated: Propert File Name : test.properties Key Name : test_key_name old key value: test_key_old_value new key value : test_key_new_value New Properties Added: Propert File Name : test.properties Key Name : test_new_key_name new key value : test_new_key_value Old Properties Deleted: Propert File Name : test.properties Key Name : test_old_key_name old key value : test_old_key_value (Based on the criteria there might be multiple outputs in each section) Any hint on how to get started on this will be highly appreciable. |
what do you have written so far? you'll find we are more readily willing to help sometime even complete the entire script for you once you have something you have done yourself.
|
Also the current description and examples are particularly vague and do not necessarily match up. ie how does a property file with 'sample_key_name = sample_key_value' relate to any of the
output you have requested?? |
|
I guess what he is trying to do is whatever changes someone does in a file should be reflected in a formatted manner after running the script.
I guess the flow would be, if the file is open for editing make a backup copy of that file(so that we can compare the contents) and then edit it and then compare both the files and whatever is the difference show that in the desired formatted way. Question: a) How can we instruct when the file is open for editing make a backup copy? (I guess some cron job should be running in the background continuously to check when the file is open for editing and make the backup copy immediately) |
As he's talking about writing script to do this, you'd backup data file first, before doing anything else.
To use shell I guess I'd use a data file with key, then name/value pairs for each key and have a special value for deleted value eg <DEL>, or possibly blank. One rec per property & csv format possibly... If you're going to want to keep history recs, possibly a DB would be better, or maybe I'd use Perl with Tied Hashes. |
abhinav4 would seem to be proving my point about the vagueness as all answers start with "I guess"...
|
All times are GMT -5. The time now is 12:13 PM. |