株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

このようなjsonファイルがある場合

yuta:~/envsubst $ cat test.json.in
{
    "version": {
        "name": "${VERSION}",
        "released": "${DATE}",
        "vcs_tag": "${VERSION}"
    }
}
yuta:~/envsubst $

VERSIONとDATEに変数を入力

VERSION=trunk DATE=$(date +%Y-%m-%d) envsubst < test.json.in > test.json

こんな感じでファイルが生成される

yuta:~/envsubst $ cat test.json
{
    "version": {
        "name": "trunk",
        "released": "2021-07-04",
        "vcs_tag": "trunk"
    }
}
yuta:~/envsubst $

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)