From nobody Wed Apr 27 21:32:45 2022 X-Original-To: freebsd-ports@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CC2121ABAD44 for ; Wed, 27 Apr 2022 21:32:52 +0000 (UTC) (envelope-from beckman@angryox.com) Received: from nog.angryox.com (nog.angryox.com [70.164.19.87]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4KpX6C47Vsz3qCq for ; Wed, 27 Apr 2022 21:32:51 +0000 (UTC) (envelope-from beckman@angryox.com) Received: by nog.angryox.com (Postfix, from userid 1001) id 9C09095AC; Wed, 27 Apr 2022 21:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=angryox.com; s=powerfulgood; t=1651095165; bh=Qq+vdPHtBtTRyiTEPCoq6RVwMqhCqhRNZ964/rkyzyQ=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=CSKwYubWU5V9cjj+ngDEjY0MU5vxXOFhMp7mBi0fIDjjG2vQ9SdulAV12c2ppO0Hl 1RWBu8YJfyXncjtCyWD6x5tC4K/BDMkpPQV615YWAHwHD8eEPmyFLNrHEf71nvqekY OfobCVJQMwHeEn+uqa6HJmuroac1EacG/Z3I9JQo= Received: from localhost (localhost [127.0.0.1]) by nog.angryox.com (Postfix) with ESMTP id 93E049606; Wed, 27 Apr 2022 17:32:45 -0400 (EDT) Date: Wed, 27 Apr 2022 17:32:45 -0400 From: Peter Beckman To: Andrea Venturoli cc: freebsd-ports@freebsd.org Subject: Re: Fill a disk with more recent files In-Reply-To: Message-ID: References: List-Id: Porting software to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-ports List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports@freebsd.org X-BeenThere: freebsd-ports@freebsd.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1573270368-327337737-1651095165=:8011" X-Rspamd-Queue-Id: 4KpX6C47Vsz3qCq X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=angryox.com header.s=powerfulgood header.b=CSKwYubW; dmarc=none; spf=pass (mx1.freebsd.org: domain of beckman@angryox.com designates 70.164.19.87 as permitted sender) smtp.mailfrom=beckman@angryox.com X-Spamd-Result: default: False [-2.50 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[angryox.com:s=powerfulgood]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:nog.angryox.com]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; DMARC_NA(0.00)[angryox.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[angryox.com:+]; CTYPE_MIXED_BOGUS(1.00)[]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MLMMJ_DEST(0.00)[freebsd-ports]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22773, ipnet:70.164.18.0/23, country:US]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N 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--