Shell script to find out which properties are modified/added/deleted.
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.