Bash comparison between strings - equal but not equal for it

前端 未结 2 1833
遇见更好的自我
遇见更好的自我 2021-01-29 02:15

I just wanted to do a really simple comparison between 2 strings in Bash :

stat=`curl -Is $url | head -n 1` 
echo $stat
if [ \"$stat\" = \"HTTP/1.1 200 OK\" ];th         


        
2条回答
  •  耶瑟儿~
    2021-01-29 02:31

    The curl output includes a CR at the end of the lines, you need to remove it.

    stat=`curl -Is $url | head -n 1 | tr -d '\r'` 
    

提交回复
热议问题