Curl now has --etag-save and --etag-compare
--etag-save
--etag-compare
https://curl.se/docs/manpage.html#--etag-compare
You should be able to use these together as of 7.70.0
curl --etag-compare etag.txt --etag-save etag.txt http://example.org