DEV Community

loading...

Discussion on: Pointing A Domain to The Newest File In A Directory

Collapse
bgadrian profile image
Adrian B.G.

I think is the correct solution as well, but you can remove the duplicate data with a symlink.

You can update the symlink at each new xml creation, or put it as a background job.

#!/bin/bash

 ln -fs ./`ls -rt . | tail -n1` latest #symlink to the newst file
 #inotifywait -e attrib . #wait for the change or simple sleep
 sleep 0.1 #wait for the symlink to be updated

You can improve the ls with xml so you can avoid a circular symlink or other strange things.