Adding Random Number to String
by orangepeel190 from LinuxQuestions.org on (#5FRSC)
Hi There
I am having difficulties in adding a random number to a simple bash script that I am trying to get running.
Basically, I have around 10 URLs that I am wishing to cycle thru and have my script download the URL string (that is set) - randomised by their file number
Quote:
I am having difficulties with everything that I am trying to get the curl component of my script to pull down the correct URL based on the Randomised number that outputs when run.
Simply, wishing to let the script randomise the file to be downloaded (file 1-9)
I am thinking that I am missing a simple component to get this working where by the variable string in placed into the curl component to be downloaded? Maybe something missing in the file_download section of the code?
Any thoughts or suggestions to get this working?
Cheers


I am having difficulties in adding a random number to a simple bash script that I am trying to get running.
Basically, I have around 10 URLs that I am wishing to cycle thru and have my script download the URL string (that is set) - randomised by their file number
Quote:
address1="https://www.file1" address2="https://www.file2" address3="https://www.file3" address4="https://www.file4" address5="https://www.file5" address6="https://www.file6" address7="https://www.file7" address8="https://www.file8" address9="https://www.file9" Random_Number="$(( $RANDOM % 9 + 1 ))" file_download="$(address$Random_Number)" curl -SkLO $file_download |
Simply, wishing to let the script randomise the file to be downloaded (file 1-9)
I am thinking that I am missing a simple component to get this working where by the variable string in placed into the curl component to be downloaded? Maybe something missing in the file_download section of the code?
Any thoughts or suggestions to get this working?
Cheers