This is a follow on from my previous thread :- Passing date command into a variable?
Ok so effectively I would like /dev/urandom to generate 4 digits for me. And place them into a variable.
Here is an example of my bash script :-
#!/bin/bash
for (( c=0; c<=10; c++))
do
a="$(tr -dc '[:digit:]' < /dev/urandom | fold -w 4)"
echo $a
done
The only reason I wish to "Echo" the results is so I can actually see that /dev/urandom has generated 4 digits for me correctly.
For my bash script I wish to make, I need to do this programmatically as I wish to do further operation's on the generated results.
So I need not "Echo" the results. so is a="$(tr -dc '[:digit:]' < /dev/urandom | fold -w 4)"
Actually placing 4 random digits into the variable "a"? when I Echo "a" from my script I just get a hanging console and have to use "CTRL+C" to bring my console back.
All I am trying do is place 4 random digits from /dev/urandom into a variable.
I m a new to bash scripting so all advice welcome and thank you in advanced for any help or suggestions.