Bash script not waiting for wget to finish download
Solution 1:
Bash is seeing the &
symbols in the URL as a terminator of the command and executing it as a background process. If you enter any command in bash and append a &
to it, it will run it in the background and return control to the calling script or the terminal immediately. The fields between them are being executed as commands itself.
To keep bash from interpreting the URL this way, enclose the entire thing in quotes. This will make it pass the whole URL as a string parameter, and it will run as a foreground process.