LoginSignup
10
9

More than 5 years have passed since last update.

Bashで環境変数があればそれを使い、なければ指定した値を使う

Posted at

を、簡単にやる。

#!/bin/bash

PASS=${DEFAULT_PASS:-$(pwgen -s 12 1)}
echo $PASS

DEFAULT_PASSがあればそちらを使い、そうでなければpwgenを使って生成する。

10
9
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
10
9