Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Apr 2022 17:32:45 -0400
From:      Peter Beckman <beckman@angryox.com>
To:        Andrea Venturoli <ml@netfence.it>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: Fill a disk with more recent files
Message-ID:  <c54145c-ab5-9739-a75-e313776b4c7e@angryox.com>
In-Reply-To: <b92d3ed6-0ea4-ff05-b53c-4427c6234eeb@netfence.it>
References:  <b92d3ed6-0ea4-ff05-b53c-4427c6234eeb@netfence.it>

next in thread | previous in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--1573270368-327337737-1651095165=:8011
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8BIT

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
oldest.

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
beckman@angryox.com                                https://www.angryox.com/
---------------------------------------------------------------------------
--1573270368-327337737-1651095165=:8011--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?c54145c-ab5-9739-a75-e313776b4c7e>