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/bashechoecho Connecting to www.cloudflare.com...;curl -Is https://www.cloudflare.com/ > file1.txt;a=$(cat file1.txt | grep Server);echo $a;echoecho Connecting directly to www.amazon.com...;curl -Iks https://www.amazon.com/ > file2.txt;b=$(cat file2.txt | grep Server);echo $b;echoif [ $a == Server: cloudflare-nginx ]; then    echo This connection is going via CloudFlareelse    echo This connection is NOT going via CloudFlare    echo $afi 
compare string in bash
bash;shell script
The header lines being returned from the curl commands have a ^M before the newline. You could change the if to use a regex:if [[ $a =~ Server: cloudflare-nginx ]]; then    echo This connection is going via CloudFlareelse    echo This connection is NOT going via CloudFlare    echo $afiYou can also remove the \r by changing the line:a=$(cat file1.txt | tr -d '\r' | grep '^Server:');