I would like to know if it's possible to grab the newest folder inside a directory and use that in a command automatically for linux. What I am trying to achieve is the following:
There is a folder called/home/admin/web/backups/FTP/ where a software drops folders with bi-weekly backups (so inside of "FTP" you'll find folders like 2021-03-28, 2021-03-30, etc.)
I sync that over to a drive utilizing rclone (rclone copy -P /home/admin/web/backups/FTP/XXX drive:XXX) XXX being the latest folder created (I type this out manually) so in this case it'd be 2021-03-03 for example.
Is there a way to grab the name of the newest folder (say the newest folder is 2021-04-03) and then replace the "XXX" after FTP/ and drive: in that command and execute it?
Thanks in advance!