7
6

More than 5 years have passed since last update.

URLの画像やページが存在するかシェル上で確認

Posted at

curl -vのerror出力をリダイレクトして標準出力に吐き出せば良い。
http://d.hatena.ne.jp/Climber/20100707/1278493780
http://www.adminweb.jp/command/redirect/index3.html

Screenshot from 2014-09-28 11:26:39.png

 curl -v http://qiita.com/jamejammy/items/671a14ae2834c045fe27 2>&1 1>/dev/null | awk '{if($2~"HTTP") print}'

< HTTP/1.1 200 OK

 curl -v http://qiita.com/jamejammy/items/671a14ae2834c045fe26 2>&1 1>/dev/null | awk '{if($2~"HTTP") print}'

< HTTP/1.1 404 Not Found


番号だけで良いならば
Screenshot from 2014-09-28 11:29:12.png

 curl -v http://qiita.com/jamejammy/items/671a14ae2834c045fe27 2>&1 1>/dev/null | awk '{if($2~"HTTP") print $3}'

200

 curl -v http://qiita.com/jamejammy/items/671a14ae2834c045fe26 2>&1 1>/dev/null | awk '{if($2~"HTTP") print $3}'

404

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6