【Linux】curlでステータスコードを取得

「-w ‘%{http_code}\n’」オプションで取得できる。
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@PHANTOM ~]# curl -s http://192.168.0.45 -w '%{http_code}\n' | head -10 <!DOCTYPE html> <html lang="ja"> <head> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script> (adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-4568290130410677", enable_page_level_ads: true }); [root@PHANTOM ~]# |
ステータスコードのみの場合
1 2 |
[root@PHANTOM ~]# curl -s http://192.168.0.45 -w '%{http_code}\n' -o /dev/null 200 |