Is it possible to create a symbolic link to the last file in the directory?

I have a home directory in my unix block. I would like to set a number or shortcuts in it to indicate the last file in another directory, and the link will be updated if a newer file is created.

Is it possible?

So far I can get the latest file:

ls -lrt | tail -n1

thank

[EDIT]

Perhaps I could create a wrapper instead of softlink, which will find the last file and return it so that I can open / grep / delete, etc.

+5
source share
1 answer

In bash, this will result in a link to the last file or directory in the "target-directory" called "latest":

ln -s target-directory/`ls -rt target-directory | tail -n1` latest

And this will wait for the change in the "target-directory" before returning:

inotifywait -e attrib target-directory
+10
source

All Articles