teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

回答修正: curlコマンドの-sまで消してしまったのを復活

2020/01/16 05:09

投稿

Y.H.
Y.H.

スコア7918

answer CHANGED
@@ -3,7 +3,7 @@
3
3
  以下で最終行にhttp statusが付与されます。
4
4
 
5
5
  ```bash
6
- res=`curl -L google.com -w '\n%{http_code}'`
6
+ res=`curl -L google.com -w '\n%{http_code}' -s`
7
7
  body=`echo "$res" | sed '$d'`
8
8
  httpstatus=`echo "$res" | tail -n 1`
9
9
  ```

1

回答修正: curlコマンドのオプションが冗長だったので修正

2020/01/16 05:09

投稿

Y.H.
Y.H.

スコア7918

answer CHANGED
@@ -3,7 +3,7 @@
3
3
  以下で最終行にhttp statusが付与されます。
4
4
 
5
5
  ```bash
6
- res=`curl -L google.com -o - -w '\n%{http_code}\n' -s`
6
+ res=`curl -L google.com -w '\n%{http_code}'`
7
7
  body=`echo "$res" | sed '$d'`
8
8
  httpstatus=`echo "$res" | tail -n 1`
9
9
  ```