wget command help to download packages from mirror

[LEFT][LEFT] Index of /distribution/openSUSE-stable/repo/oss/suse/i586

How can i download packages with wget from that mirror with a string "alsa"?
Such as:
alsa-1.0.23-2.12.i586.rpm
alsa-devel-1.0.23-2.12.i586.rpm
alsa-oss-1.0.17-29.2.i586.rpm

Not manually downloading packages.
But i'm trying to download packages that has a string/word "alsa".
wget will automatically download those packages.

How can it be done?

Any script?
[/LEFT]
[/LEFT]

Hint :wink:

lynx -dump http://download.opensuse.org/distribution/openSUSE-stable/repo/oss/suse/i586/ | grep -i alsa

Can't get it.

Try this:

mirror="http://download.opensuse.org/distribution/openSUSE-stable/repo/oss/suse/i586/"
lynx -dump $mirror | awk '/http.*alsa.*\.rpm$/ {print "wget -c "$2 | "sh"}'

Does not work.

As far as I know wget does not support HTTP globbing. You can try something like:

#!/bin/ksh
URLS="$(wget -qO- http://download.opensuse.org/distribution/openSUSE-stable/repo/oss/suse/i586/ | sed -n 's/.*<a href="\(.*alsa.*.rpm\)">.*/\1/p')"
for file in $URLS; do wget $file; done

The output has some problem, more files than the expect, such as pyalsa-1.0.22-1.8.i586.rpm.

#!/bin/ksh
MIRRORURL="http://download.opensuse.org/distribution/openSUSE-stable/repo/oss/suse/i586/"
URLS="$(wget -qO- $MIRRORURL | awk -v RS=" " -F \" '/href=.*rpm\">/&&$2~/^alsa/{print $2}' )"
for file in $URLS; do wget $MIRRORURL/$file; done

Doesn't Suse have a native tool for this? Fedora does and a Suse repository can't be too different.

If it is ftp mirror then what would be the command?

Yup, but the O/P did not specify that he needed the string at the beginning of the line... unless we look at the example he posted. :slight_smile:

wget ftp://repository/*alsa*.rpm