Re: Terminal – ls-like command for http directories?
Johnny Rosenberg
gurus.knugum at gmail.com
Sat May 25 16:42:22 UTC 2013
2013/5/25 Florian Diesch <diesch at spamfence.net>:
> Am Sat, 25 May 2013 14:20:57 +0200
> schrieb Johnny Rosenberg <gurus.knugum at gmail.com>:
>
>> Is this possible?
>>
>> Okay, an example:
>> I have a script that downloads and installs unetbootin to my system. I
>> run the script like this:
>>
>> ./Install.sh 583
>>
>> This downloads and ”installs” Unetbootin 5.83, which means it uses
>> wget to download the file, then moves the file to a proper place and
>> finally adds a link to it in ~/bin so I can run it by only typing:
>> unetbootin
>>
>> Now, for this to work, I first need to find out what is the latest
>> version, for instance by looking it up in my web browser. Then I can
>> run my install script.
>>
>> Of course it would be more convenient if the script could find the
>> latest version for me.
>>
>> The latest version (today, 2013-05-25) is:
>> http://tenet.dl.sourceforge.net/project/unetbootin/UNetbootin/583/unetbootin-linux-583
>>
>> So what I need is a command like:
>> some_ls-like_command
>> "http://tenet.dl.sourceforge.net/project/unetbootin/UNetbootin/"
>> Then I guess I would have a loop that determines the highest value
>> somehow, but I guess I will figure that part out.
>
> You can download the page and use awk and friends to the highest
> value, e.g.
>
> ----------------------------------------------------------------------
> URL='http://tenet.dl.sourceforge.net/project/unetbootin/UNetbootin/'
>
> wget -q -O- "$URL" | \
> awk -F '"|/' '/^<tr class/ && !/Custom/ {print $4 }' | \
> sort -n | tail -1
> ----------------------------------------------------------------------
Thanks! Seems to be twice as fast as what I did, at least if I omit
the sort -n command, which doesn't seem to be necessary, since the
list is sorted anyway.
Since I'm not fond of including code that I don't fully understand,
will you please explain that ”/^<tr class/ && !/Custom/” thing? I have
used awk a couple of times, but only the most basic things like -F and
{print $n} and maybe a few more things.
Does the ^ mean ”start of line”?
I guess ! means ”not”, right?
And && means ”and”?
The slashes, what exactly do they mean? Do they work like some kind of
parentheses or quotation marks?
If I try my best to translate it all to ”plain English”, it would be
something like: Lines that start with ”<tr class” and don't contain
”Custom”. Is that right?
Johnny Rosenberg
>
>
> --
> Privacy Indicator
> Unity appindicator to switch privacy settings
> <http://www.florian-diesch.de/software/indicator-privacy/>
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
More information about the ubuntu-users
mailing list