I am trying to find a clever way to figure out if the file passed to sed has been altered successfully or not.
Basically, I want to know if the file has been changed
You can diff the original file with the sed output to see if it changed:
sed -i.bak s:$pattern:$new_pattern: "$filename" if ! diff "$filename" "$filename.bak" &> /dev/null; then echo "changed" else echo "not changed" fi rm "$filename.bak"