Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL Command in linux to return http response code

Please i want to use the cURL command in linux OS to return as a result just the http response code which is "200" if it is okey

am using that command:

curl -I -L domain.com

but this is returning for me a full text like this

HTTP/1.1 **200** OK
Date: Thu, 27 Feb 2014 19:32:45 GMT
Server: Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.4.19
X-Powered-By: PHP/5.4.19
Set-Cookie: PHPSESSID=bb8aabf4a5419dbd20d56b285199f865; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding,User-Agent
Content-Type: text/html

so please i just need the response code and not the whole text

Regards

like image 540
user3178889 Avatar asked Oct 21 '25 12:10

user3178889


1 Answers

curl -s -o out.html -w '%{http_code}' http://www.example.com
like image 181
Sabuj Hassan Avatar answered Oct 23 '25 01:10

Sabuj Hassan