I tried to write the following script to compare two HTML response headers, however i am hitting the else condition despite by printing the header stored in the variable $a I am getting the exact same value.
#!/bin/bash
echo
echo "Connecting to www.cloudflare.com...";
curl -Is "https://www.cloudflare.com/" > file1.txt;
a=$(cat file1.txt | grep Server);
echo "$a";
echo
echo "Connecting directly to www.amazon.com...";
curl -Iks "https://www.amazon.com/" > file2.txt;
b=$(cat file2.txt | grep Server);
echo "$b";
echo
if [ "$a" == "Server: cloudflare-nginx" ]; then
echo "This connection is going via CloudFlare"
else
echo "This connection is NOT going via CloudFlare"
echo "$a"
fi
serverheader.