In bash I want to prompt user for input in a script. Lets say the input is:
#!/bin/bash
echo "Please enter a number."
read NUM
# User enters "12345678"
How can I use the next command to generate a random number and then check to see if that number is the same as one of the digits of the user input?
tr -dc '0-9' </dev/urandom | head -c 1
I want to be able to check to see if the generated number matches any of the digits in the user input that I choose. I want to be able to compare the generated number with any of the digits in the user input without having to make the user input be separate variables.
(edit) If the input is: 12345678 I want the generator to generate numbers until the 1's place is matched, then the 10's place, then the 100's place and so on until there is a full string match. I need the tr command output to be compared with a single place value at a time in sequence.
How would I do this in bash?