This script add to HTML file strings from another file. And check if these strings already exist.
#!/bin/bash
AddNewString()
{
stringN="`sed -n ''"$stringNum"'p' $HTMLFILE`"
if [ "$stringN" != "$stringA" ]; then
sed -i ''"$stringNum"'i'"$stringA"'' $HTMLFILE
fi
return 1
}
echo "Starting update ..."
echo "Starting deletion ..."
file="./xen-centos.html"
file_for_replace="./new-header.html" echo "Strings were deleted"
echo "Starting addition ..." FILELIST="/tmp/phn-site-update-temp-file-list.txt"
find ./khmel.org/ -name "*.html" | grep -v -e index.html -e notes.html -e links.html -e about.html > $FILELIST
while read HTMLFILE
do
stringNum=1
echo "Changing of: $HTMLFILE"
while read Line
do
sed 's///' $HTMLFILE 1>/dev/null
sed 's///' $HTMLFILE 1>/dev/null
stringA="$Line"
AddNewString $HTMLFILE $stringA $stringNum
let stringNum=stringNum+1
done < $file_for_replace
done < $FILELIST
rm -f $FILELIST
echo "Update Finished"