LoginSignup
7
8

More than 5 years have passed since last update.

shellscriptで外部コマンドに変数を渡す時はevalを使う

Posted at
eval.sh
#!/bin/bash

URL="https://www.google.co.jp/"

eval curl -o /dev/null --silent --head --write-out \
    '"STATUS CODE : %{http_code}\n"' ${URL}

evalは変数を展開してくれる。

$ sh eval.sh
STATUS CODE : 200

ど、どうやるんだっけ...となったので忘れないようにメモ

7
8
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
8