2

On my web-browser application I have a list of folder by when pictures are getting taken via security camera. Folder structure is something like:

~/security_camera/test_11_11_2011/.jpg ~/security_camera/test_12_12_2012/.jpg ... ... ... ... ~/security_camera/test_18_12_2020/*.jpg

From the linux prompt I can quickly create a link

ln -sf $(ls -d ~/security/camera/test_* | tail -1 ) LAST_UPDATED_FOLDER

That will create a link in the same folder and that I can access to see the latest folder. Is there a way to make the above link dynamic? I would not have a cronjob creating that link, but basically everytime that a new folder is getting created, then link should point to latest folder from time point of view.

Command above is not refreshing that link automatically.

Marco smdm
  • 1,020
  • 1
  • 15
  • 25
  • You need [this](https://stackoverflow.com/questions/1015678/get-most-recent-file-in-a-directory-on-linux) to get the newest file. – costaparas Dec 18 '20 at 12:57
  • That is just getting the latest, but I would like to have a link that is refreshing alone under the folder. ls -lArt will not really help with a watch behind as the command will not return. – Marco smdm Dec 18 '20 at 16:27
  • I wasn't suggesting to use `watch` as done in the comment. I was suggesting to use the command `ls -Art | tail -n 1` as in the answer *instead* of your current `ls` command. – costaparas Dec 18 '20 at 23:16
  • I tried that, but the link will not be updated automatically if I am using the command above, just instead of -d with -Art. Is something wrong I am doing? – Marco smdm Dec 25 '20 at 09:57

0 Answers0