DIR=/opt/minefield32 LATEST="$(wget -O - -q http://nightly.mozilla.org | grep "Linux Intel" | tail -n1 | sed -r 's%.+(http://.+\.tar.bz2).+%\1%')" FILE=$(mktemp /tmp/nightlyXXXXXX.tar.bz2) mkdir -p "$DIR" find "$DIR" -mindepth 1 -delete wget -O "$FILE" "$LATEST" if [[ $? -ne 0 ]]; then echo "Error downloading nightly." >&2 exit 1 fi tar xjvf "$FILE" -C "$DIR" --strip-components 1 rm "$FILE"