I first get file size info with curlfileSize=$( curl http://linux.die.net/include/sys/ioctl.h --head | grep Content-Length | awk '{print $2}')echo $fileSize is 1825then I download the file and check the sizedownloadedSize=$(wc -c ioctl.h | awk '{print $1}')echo $downloadedSize is 1825then I want to compare these variables. but condition always falseif [[ $fileSize == $downloadedSize ]]; then    echo success  else    echo fail  fiI tried theseif [ $fileSize == $downloadedSize ]; thenif [ $fileSize == $downloadedSize ]; thenif [[ $fileSize == $downloadedSize ]]; thenand -eq instead of ==What is wrong ?
if always false with equal variables
shell script
Running :$ echo $fileSize | od -c0000000   1   8   2   5  \r  \n0000006$ echo $downloadedSize | od -c0000000   1   8   2   5  \n0000005shows you in the first case there is a carriage return appended to the value (http-headers have dos line terminations: CRLF) while the second variable is correct. Strip the CR (\r) and your test will work. e.g.:fileSize=$( curl http://linux.die.net/include/sys/ioctl.h --head |   awk '/Content-Length/ {gsub(\r,); print $2; exit}')