Created
May 23, 2024 22:42
-
-
Save mike-neck/cd113604e4ce86eed7d4e2ccb0dbb3dd to your computer and use it in GitHub Desktop.
ランダム文字列を生成するシェルスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function generateRandomAlNumString() { | |
local chars=($(echo {a..z} {A..Z} {0..9})); | |
local string=() | |
local index | |
local loopIndex | |
for loopIndex in {1..16}; do | |
index="$(( RANDOM % 62 ))" | |
index="$(( index + 1 ))" | |
string+=("${chars[index]}") | |
done | |
local oldfs="${IFS}" | |
IFS="" | |
echo -n "${string[*]}" | |
IFS="${oldfs}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment