#!/bin/bash

#Loop through all HTML files in directory and all subdirectories
find . -name "*.html" -type f -print0 | while read -d '' file; do

#Check if file exists and is readable
if [ -r "$file" ]; then
# Check if file contains the line "http://us.rd.yahoo.com/302/" or "http://us.rd.yahoo.com/301/-http://search.yahoo.com/search"
if grep -q -E "http://us.rd.yahoo.com/(302/|301/*-http://search.yahoo.com/search)" "$file"; then
# If file contains the line, delete the file
rm "$file"
echo "Deleted $file due to 302/301 error."
fi
fi
done
