Reputation: 496
I need to perform a md5sum check after downloading a zip file. My shell script looks like this:
wget $1 -O "$5.zip"
md5pkg=md5sum $5.zip
#perform check and other operations with md5pkg
Now, the check is performed before download completion, resulting to an error since the .zip file hasn't bean downloaded yet. What's the best approach to solve this problem?
thanks in advance.
Upvotes: 1
Views: 530
Reputation: 531085
If there is an ampersand in the value of $1
, it will be parsed as the background operator, allowing the rest of your script to proceed. Quote it:
wget "$1" -O "$5.zip"
md5pkg=$( md5sum "$5.zip" )
In this case, I would expect the portion after the ampersand to be an invalid shell command and cause an error, which you don't mention. There may be other problems, but you should quote your variables in any case.
Upvotes: 1