ランダム値取得

(16)
--0以上100未満の数値

awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 100) }'

while true;do
awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 100) }'
done

--10文字
cat /dev/urandom | base64 | fold -w 10 | head -n 1

while true;do
cat /dev/urandom | base64 | fold -w 10 | head -n 1
done

--日付(2001年~2020年)

while true;do
d=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 365 * 20) }'`
h=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 24) }'`
m=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 60) }'`
s=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 60) }'`
date -d "20010101 00:00:00 ${d} days ${h} hours ${m} minutes ${s} seconds" "+%Y%m%d %T"
done

 

(18)

--0以上100未満の数値

awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 100) }'

while true;do
awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 100) }'
done

--10文字
cat /dev/urandom | base64 | fold -w 10 | head -n 1

while true;do
cat /dev/urandom | base64 | fold -w 10 | head -n 1
done

--日付(2001年~2020年)

while true;do
d=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 365 * 20) }'`
h=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 24) }'`
m=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 60) }'`
s=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 60) }'`
date -d "20010101 00:00:00 ${d} days ${h} hours ${m} minutes ${s} seconds" "+%Y%m%d %T"
done

 


(9)
--0以上100未満の数値

awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 100) }'

while true;do
awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 100) }'
done

--10文字
cat /dev/urandom | base64 | fold -w 10 | head -n 1

while true;do
cat /dev/urandom | base64 | fold -w 10 | head -n 1
done

--日付(2001年~2020年)

while true;do
d=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 365 * 20) }'`
h=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 24) }'`
m=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 60) }'`
s=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 60) }'`
date -d "20010101 00:00:00 ${d} days ${h} hours ${m} minutes ${s} seconds" "+%Y%m%d %T"
done

 

(7)

--0以上100未満の数値

awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 100) }'

while true;do
awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 100) }'
done

--10文字
cat /dev/urandom | base64 | fold -w 10 | head -n 1

while true;do
cat /dev/urandom | base64 | fold -w 10 | head -n 1
done

--日付(2001年~2020年)

while true;do
d=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 365 * 20) }'`
h=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 24) }'`
m=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 60) }'`
s=`awk 'BEGIN{ srand('"$RANDOM"'); print int(rand() * 60) }'`
date -d "20010101 00:00:00 ${d} days ${h} hours ${m} minutes ${s} seconds" "+%Y%m%d %T"
done

 

(2012R2)
https://win.just4fun.biz/?%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%83%97%E3%83%AD%E3%83%B3%E3%83%97%E3%83%88/%E4%B9%B1%E6%95%B0%E3%82%92%E7%99%BA%E7%94%9F%E3%81%95%E3%81%9B%E3%82%8B%E3%83%BB%E4%BB%BB%E6%84%8F%E3%81%AE%E7%AF%84%E5%9B%B2%E3%81%AE%E4%B9%B1%E6%95%B0%E3%82%92%E7%99%BA%E7%94%9F%E3%81%95%E3%81%9B%E3%82%8B
https://monaski.hatenablog.com/entry/2015/09/29/202421


--0以上100未満の数値

--DOSコマンド

set /a R=%RANDOM%*100/32768
echo %R%

@echo off
:LOOP
set /a R=%RANDOM%*100/32768
echo %R%
goto :LOOP
exit /b 0


--PowerShell

Get-Random -Maximum 100

while ($true) {
Get-Random -Maximum 100
}

--


--10文字


Add-type -AssemblyName System.Web;[System.Web.Security.Membership]::GeneratePassword(10,0)

while ($true) {
Add-type -AssemblyName System.Web;[System.Web.Security.Membership]::GeneratePassword(10,0)
}

 


--日付(2001年~2020年)

$start=[DateTime]::ParseExact("2001/01/01 00:00:00","yyyy/MM/dd hh:mm:ss", $null);

$y=Get-Random -Maximum 21
$m=Get-Random -Maximum 12
$d=Get-Random -Maximum 365
$h=Get-Random -Maximum 24
$mi=Get-Random -Maximum 60
$s=Get-Random -Maximum 60
$start.AddYears($y).AddMonths($m).AddDays($d).AddHours($h).AddMinutes($mi).AddSeconds($s)

while ($true) {
$start=[DateTime]::ParseExact("2001/01/01 00:00:00","yyyy/MM/dd hh:mm:ss", $null);
$y=Get-Random -Maximum 21
$m=Get-Random -Maximum 12
$d=Get-Random -Maximum 365
$h=Get-Random -Maximum 24
$mi=Get-Random -Maximum 60
$s=Get-Random -Maximum 60
$start.AddYears($y).AddMonths($m).AddDays($d).AddHours($h).AddMinutes($mi).AddSeconds($s)
}