LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-02-2014, 01:44 AM   #1
seprob
Member
 
Registered: Sep 2008
Posts: 50

Rep: Reputation: 15
Download the newest file


Hello! As I wrote in the topic; how to download (by wget or something) the newest package from given HTTP directory? Package looks like "package_v14.14.0.tar.gz".
 
Old 12-02-2014, 01:50 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,280
Blog Entries: 24

Rep: Reputation: 4227Reputation: 4227Reputation: 4227Reputation: 4227Reputation: 4227Reputation: 4227Reputation: 4227Reputation: 4227Reputation: 4227Reputation: 4227Reputation: 4227
Code:
wget http;//url.of.site/path/to/package_123.tar.gz
... should do it.
 
Old 12-02-2014, 03:51 AM   #3
seprob
Member
 
Registered: Sep 2008
Posts: 50

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by astrogeek View Post
Code:
wget http;//url.of.site/path/to/package_123.tar.gz
... should do it.
You dont't understand. I have many files in some directory. I want to write a script which downloads the newest file.
 
Old 12-02-2014, 03:55 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,180

Rep: Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394
you need to find a way to know the newest, http is not the right way (you may or may not read directory content and you cannot modify it from the client side)
 
1 members found this post helpful.
Old 12-09-2014, 06:28 AM   #5
seprob
Member
 
Registered: Sep 2008
Posts: 50

Original Poster
Rep: Reputation: 15
Solution is like this:
Quote:
wget -q -O releases.html http://your.page/directory/
cat releases.html | grep -o your_packages.*your_extension | sed 's/..............$//' | tail -1
 
Old 12-09-2014, 07:58 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,180

Rep: Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394Reputation: 7394
wget -O - http://... | grep -o ... | sed ... | tail
but I'm not really sure about the result. Does it always return the latest?
 
Old 12-09-2014, 08:09 AM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this web directory is sorted by modified date:
http://schneidz.noip.me/temp/?C=M;O=A

perhaps you can scrape the html to wget the last entry ?
 
Old 12-09-2014, 11:18 AM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
As you can see from the above, there is no universal way to do it. You need to tailor your solution to the particular server you're pulling data off of. How do you know one file is newer than another? Are there version numbers? Modification dates? How are things named?

First determine how YOU would identify the newest file, and then write a set of instructions that will allow a script to do the same.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying every file except the newest one frufan Linux - General 3 05-13-2013 10:33 AM
Find newest file capella Linux - Software 9 04-28-2012 04:26 AM
Should I download newest Linux kernel 2.6 version? trien27 Linux - Kernel 2 06-06-2009 04:47 PM
newest data file wolfindark Linux - Newbie 1 07-04-2008 01:42 AM
download newest files on ftp exodist Linux - Networking 0 03-06-2004 03:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration