Re: Fill a disk with more recent files

From: Peter Beckman <>
Date: Wed, 27 Apr 2022 21:32:45 UTC
I feel like `ls` or `find` and some creative sorting after the fact would
do it.

ls -laRrt sort of works, but it doesn't output subdirectory files in order.

find doesn't have any sorting.

You could use the `ls` flag `-D format`:

 	When printing in the long (-l) format, use format to format the
 	date and time output.  The argument format is a string used by
 	strftime(3).  Depending on the choice of format string, this may
 	result in a different number of columns in the output.  This
 	option overrides the -T option.  This option is not defined in
 	IEEE Std 1003.1-2001 (“POSIX.1”).

Output the date as something that is more easily sortable, then pipe that
through `sort -rn` and now you have a list of files in order of newest to

Remove the directories with ` | egrep -v '^d'` and you've got a sorted list of files.

Use `cut` to trim just the file path and you have a list of files.

Maybe rsync can take in that list? Or you can use that list as an input for xargs or something?

Get creative!

web1 : / --> ls -lart -D '%Y%m%d%H%M%S' | sort -rnk 6
drwxrwxrwt  26 root  wheel   323 20220427212946 tmp/
drwxr-xr-x  27 root  wheel   117 20220415015709 etc/
drwxr-xr-x  21 root  wheel    29 20200515173805 ./
drwxr-xr-x  21 root  wheel    29 20200515173805 ../
-rw-------   1 root  wheel  4096 20200515173805 entropy
drwxr-xr-x  25 root  wheel    25 20200515173804 var/
dr-xr-xr-x  11 root  wheel   512 20200515173758 dev/
drwxr-xr-x   8 root  wheel     8 20190830012952 data/
drwxr-xr-x   3 root  wheel     3 20190830012952 zroot/
drwxr-xr-x   4 root  wheel    17 20190510202515 root/
drwxr-xr-x   4 root  wheel    61 20190303200651 lib/
drwxr-xr-x  16 root  wheel    16 20190302233620 usr/
drwxr-xr-x   2 root  wheel   150 20190302183503 rescue/

On Wed, 27 Apr 2022, Andrea Venturoli wrote:

> Hello.
> Suppose I have a large storage of files and a smaller disk (backup).
> I need to copy as much as I can from source to target and I want the most 
> recent files.
> Before I start scripting and reinvent the wheel, is there some tool already?
> bye & Thanks
> 	av.

Peter Beckman                                                  Internet Guy