I have a file ( properties.file) with different (key=value) values, as below
agent.x=xyz
agent.y=xyz
agent.z=xyz
I have some other files in the system in different locations with different (key=value) values.
example file is properties1.txt
agent.x=123
method=xyz()
example file is properties2.txt
agent.y=xyz
method=adc()
Now I am in need of a program which reads the first file properties.file,
read all the keys, i.e agent.x,agent.y and then compare them with the files properties1.txt and properties2.txt.
If it finds any key which is not in any of the properties1.txt and properties2.txt it has to report an error.
as an example agent.z in properties.file is not present in any of properties1.txt and properties2.txt
it has to report error only once, saying key is not present.
I am in need of this solution, please help me in this.
#!/bin/sh
for f in `cat properities.txt`
do
grep -w "$f" properities1.txt
if [ $? -eq 0 ];then
sed '/'$f'/d' properities1.txt > out.lst
mv out.lst properities.1txt
break;else
grep -w $f properities2.txt
if [ $? -eq 0 ];then
sed '/'$f'/d' properities2.txt > out.lst
mv out.lst properities2.txt
break;else
echo "$f - Not present in any of the properities file"
sed '/'$f'/d' properities2.txt > out.lst
mv out.lst properities2.txt
break;fi;fi;
done
if you try now...this will not remove any data from the files..
#!/bin/sh
for f in `cat properities.txt`
do
grep -w "$f" properities1.txt
if [ $? -eq 0 ];then
break;else
grep -w $f properities2.txt
if [ $? -eq 0 ];then
break;else
echo "$f - Not present in any of the properities file"
break;fi;fi;
done