-1

I want to be able to have a generic link to the latest version on of file available for download to make things easier for clients. Example: http://server.web.net/Adium/Adium-1.5.10.4.pkg If it could be http://server.web.net/Adium/LATEST

The scripting side works fine, I just can't figure out the alias/link part.

latestfile=`find *.pkg | sort | tail -n 1`
echo $latestfile

This gets the correct file.

Glorfindel
  • 4,057
user2720970
  • 576
  • 4
  • 10
  • Not sure I follow your question, but the answer seems to be to store the latest file on the server as “latest.pkg” and replace it as often as necessary - the download script will always take that one... – Solar Mike Jul 30 '18 at 08:43
  • 1
    What you yo mean you can't figure out the alias/link part? When you create the link, what fails? – Allan Jul 30 '18 at 08:54
  • 1
    This question should not be put on hold because of "software development", as the rules clearly specify that shell scripting questions are encouraged here. – jksoegaard Jul 30 '18 at 13:08
  • @user2720970 To answer your question: You can create the link using the following command: "ln -s $latestfile LATEST". – jksoegaard Jul 30 '18 at 13:08
  • @jksoegaard now that the question is reopened, you might want to write/expand that into an answer. – Glorfindel Jul 31 '18 at 11:59
  • Also, please keep in mind that find *.pkg | sort sorts by name, not by date, so you rely on "sane" filenames here (and nobody touching any old files). – nohillside Jul 31 '18 at 12:18
  • Just stressing that find *.pkg | sort is not sorting by the version numbers of the packages. – fd0 Jul 31 '18 at 12:24

1 Answers1

1

You can create a symbolik link using the following command:

ln -s "$latestfile" LATEST

When you access LATEST you will really access the actual file, so no copying of data takes place - and no extra space is used.

Depending on your web server, you might need to allow the use of symbolic links for that directory.

fd0
  • 10,708
jksoegaard
  • 77,783