Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2806

[Linux] ランダム文字列を出力

$
0
0
Linux環境にてパスワードやパスフレーズ等の設定に使うランダム文字列を生成 条件:アルファベット大文字 (I,Oを除く)、小文字 (lを除く)、数字 (0-9)、記号 (#,?,!,_)を入れること cat /dev/urandom | tr -dc 'a-km-zA-HJ-NP-Z0-9#?_!' | fold -w 8 | head -n 300 | grep '[#?_!]' | grep [A-Z] | grep [a-z] | grep [0-9] | uniq | shuf -n 1 cat /dev/urandom ランダムな文字列を生成 tr -dc 'a-km-zA-HJ-NP-Z0-9#?_!' 条件の含めたい文字 fold -w 8 8文字 head -n 300 行頭から300文字 grep '[#?_!]' grep [A-Z] grep [a-z] 条件に合致しているか絞り込み uniq 念のため重複行の取り除き shuf -n 1 ランダムの1行を出力 コマンド実行例 $ cat /dev/urandom | tr -dc 'a-km-zA-HJ-NP-Z0-9#?_!' | fold -w 8 | head -n 300 | grep '[#?_!]' | grep [A-Z] | grep [a-z] | grep [0-9] | uniq | shuf -n 1 P?!?0QRo もうすこし簡略化できるかも

Viewing all articles
Browse latest Browse all 2806

Trending Articles