I need to compare if the 2nd line of the input file contains the string premium-world-check.xsd. If it is present, I need not do anything. If it is not present, I need to prepend to another file.
I have below input file,
<?xml version="1.0" encoding="UTF-8"?>
<records xmlns:xsi="http://ift.tt/ra1lAU" xsi:noNamespaceSchemaLocation="premium-world-check.xsd">
<record category="INDIVIDUAL">
<tag1>
<tag2>
....
</tag2>
</tag1>
Below is my code,
xsdFlag=`sed -n '2p' ${myInputFile}`
if [ $xsdFlag == *"premium-world-check.xsd"* ]
then
echo "Prepending not required";
else
echo "<records xmlns:xsi="http://ift.tt/ra1lAU" xsi:noNamespaceSchemaLocation="premium-world-check.xsd">" | cat - ${myInputFile} > wcTemp.xml && mv wcTemp.xml ${myInputFile}
echo "<?xml version="1.0" encoding="UTF-8"?>" | cat - ${myInputFile} > wcTemp.xml && mv wcTemp.xml ${myInputFile}
echo "PREPENDING:"
fi
I am getting Unknow operator in my if condition.
Aucun commentaire:
Enregistrer un commentaire