shell script 變數的預設值

[客家話, hak-Hant-TW]

有這種需要,尋一下網路看到這篇有寫,試捯毋會麻煩,記一下。

#!/bin/sh
$DEFAULT_VAR="VALUE"
VAR="${VAR-$DEFAULT_VAR}"

Leave a Reply

Your email address will not be published. Required fields are marked *