Article 5FRSC Adding Random Number to String

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:
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
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?

Cheerslatest?d=yIl2AUoC8zA latest?i=W_M2l0X5TC0:5_crPd1DK9o:F7zBnMy latest?i=W_M2l0X5TC0:5_crPd1DK9o:V_sGLiP latest?d=qj6IDK7rITs latest?i=W_M2l0X5TC0:5_crPd1DK9o:gIN9vFwW_M2l0X5TC0
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments