I have a working piece of code that I cant integrate into a for loop. The code updates the first 51 lines of each .html file in the directory to match the index.html file. This is the code that is working:
tmp=$(mktemp) &&
{ head -n 51 index.html; tail -n +52 alt.html; } > "$tmp" &&
mv -- "$tmp" alt.html
This is the for loop that isn't working:
FILES="/run/media/george/General/testing/*.html"
for f in $FILES;
do
if $f = index.html
then
echo "skip main file"
else
echo "Updating $f file..."
tmp=$(mktemp) &&
{ head -n 51 index.html; tail -n +52 $f; } > "$tmp" &&
mv -- "$tmp" $f
fi
done
This code just deletes the code in all the html files. What have I done wrong in this loop?