I have some directories:
drwxr-xr-x 10 shamoon staff 320B Mar 20 10:05 dryrun-20200320_140542-1vbczul4
drwxr-xr-x 10 shamoon staff 320B Mar 20 10:06 dryrun-20200320_140605-uze15jta
drwxr-xr-x 10 shamoon staff 320B Mar 20 10:06 dryrun-20200320_140644-193bynci
drwxr-xr-x 13 shamoon staff 416B Mar 20 10:07 dryrun-20200320_140721-fuv399ji
drwxr-xr-x 13 shamoon staff 416B Mar 20 10:08 dryrun-20200320_140810-34dim70r
drwxr-xr-x 14 shamoon staff 448B Mar 20 10:10 dryrun-20200320_140935-138yuidx
drwxr-xr-x 14 shamoon staff 448B Mar 20 10:23 dryrun-20200320_141044-35pfvec6
drwxr-xr-x 14 shamoon staff 448B Mar 20 11:14 dryrun-20200320_151418-14g88zfr
drwxr-xr-x 14 shamoon staff 448B Mar 20 12:11 dryrun-20200320_151800-gf551inz
drwxr-xr-x 14 shamoon staff 448B Mar 20 12:21 dryrun-20200320_161134-wyu9kaxu
I want to set up a symlink to the most recent. Now, there may be more recent directories created, so ideally, the symlink should also automatically update. Is this possible?
cron
job doing a simpleln -s $(ls - t | head -n 1) link_name
. – Mar 20 '20 at 16:43ln -sf $DIR latest
when this software runs (e.g. if it is a python script or something like that). Note that you need the-f
for when the symlink already exists. – user7761803 Mar 21 '20 at 07:32