Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Unix weanies are as bad at this as anyone. -- Larry Wall in <199702111730.JAA28598@wall.org>


devel / comp.unix.shell / tar files sort order by date or numeric name

SubjectAuthor
* tar files sort order by date or numeric nameJanis Papanagnou
+* Re: tar files sort order by date or numeric nameAxel Reichert
|`- Re: tar files sort order by date or numeric nameJanis Papanagnou
+* Re: tar files sort order by date or numeric namemarrgol
|`* Re: tar files sort order by date or numeric nameJanis Papanagnou
| `- Re: tar files sort order by date or numeric nameJanis Papanagnou
+* Re: tar files sort order by date or numeric nameChristian Weisgerber
|+- Re: tar files sort order by date or numeric nameJanis Papanagnou
|`* Re: tar files sort order by date or numeric nameBrian Patrie
| +* Re: tar files sort order by date or numeric nameAxel Reichert
| |`- Re: tar files sort order by date or numeric nameBrian Patrie
| `- Re: tar files sort order by date or numeric nameJanis Papanagnou
+* Re: tar files sort order by date or numeric nameHelmut Waitzmann
|+* Re: tar files sort order by date or numeric nameJanis Papanagnou
||`* Re: tar files sort order by date or numeric nameBrian Patrie
|| `- Re: tar files sort order by date or numeric nameJanis Papanagnou
|`* Re: tar files sort order by date or numeric nameSpiros Bousbouras
| `* Re: tar files sort order by date or numeric nameHelmut Waitzmann
|  `* Re: tar files sort order by date or numeric nameSpiros Bousbouras
|   +- %s in strftime(3) vs. %s in find(1) (Was: tar files sort order by date or numeriKenny McCormack
|   `- Re: tar files sort order by date or numeric nameHelmut Waitzmann
`* Re: tar files sort order by date or numeric nameAxel Reichert
 `* Re: tar files sort order by date or numeric nameJanis Papanagnou
  `- Re: tar files sort order by date or numeric nameAxel Reichert

1
tar files sort order by date or numeric name

<t53j3r$85d$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5290&group=comp.unix.shell#5290

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: tar files sort order by date or numeric name
Date: Fri, 6 May 2022 18:41:31 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <t53j3r$85d$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 6 May 2022 16:41:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3d844a5ba71ae66c6eeb09f67f1a84e3";
logging-data="8365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Q+Ot1Bqp3ELHBfZEAtvpE"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:iWYI9QXkGeaZEVAE/+nZzv6m/lY=
X-Mozilla-News-Host: news://news.eternal-september.org:119
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 6 May 2022 16:41 UTC

I want the files in a tar archive in sorted form. (Using GNU tar.)
Either by date of the file or by its name (containing a number).
For example I want these three files in sorted order like depicted:
rfc748.txt
rfc7168.txt
rfc8774.txt

I can add the files incrementally one by one to an empty archive,
but I wanted to know whether there's a trick that I missed to fill
the archive in one go, like tar cf sorted.tgz dir-with-files/

On a quick search and man page inspection I couldn't see anything.

Janis

Re: tar files sort order by date or numeric name

<87mtfuk1cs.fsf@axel-reichert.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5291&group=comp.unix.shell#5291

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mai...@axel-reichert.de (Axel Reichert)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Fri, 06 May 2022 19:38:43 +0200
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <87mtfuk1cs.fsf@axel-reichert.de>
References: <t53j3r$85d$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="dbcd44c53ae7a8567a0399ef77d99af0";
logging-data="31656"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gxET8aYTMzzYxg2s6jHWV1QDMGDtekDE="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:CByh+JHE8dybua9i4+x9PQ6Lg3c=
sha1:xzKVs1eqtJWF/DErxVFmSx2TKrE=
 by: Axel Reichert - Fri, 6 May 2022 17:38 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

> I want the files in a tar archive in sorted form. (Using GNU tar.)
> Either by date of the file or by its name (containing a number).
> For example I want these three files in sorted order like depicted:
> rfc748.txt
> rfc7168.txt
> rfc8774.txt
>
> I can add the files incrementally one by one to an empty archive,
> but I wanted to know whether there's a trick that I missed to fill
> the archive in one go, like tar cf sorted.tgz dir-with-files/

I assume that something along

ls -tr dir-with-files/ | xargs tar cf sorted.tgz

is too brittle for you?

Best regards

Axel

Re: tar files sort order by date or numeric name

<6275648d$0$454$65785112@news.neostrada.pl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5292&group=comp.unix.shell#5292

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
Subject: Re: tar files sort order by date or numeric name
Newsgroups: comp.unix.shell
References: <t53j3r$85d$1@dont-email.me>
From: marr...@address.invalid (marrgol)
Date: Fri, 6 May 2022 20:10:21 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <t53j3r$85d$1@dont-email.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 23
Message-ID: <6275648d$0$454$65785112@news.neostrada.pl>
Organization: Telekomunikacja Polska
NNTP-Posting-Host: 176.111.237.144
X-Trace: 1651860621 unt-rea-a-02.news.neostrada.pl 454 176.111.237.144:54738
X-Complaints-To: abuse@news.neostrada.pl
 by: marrgol - Fri, 6 May 2022 18:10 UTC

On 06/05/2022 at 18.41, Janis Papanagnou wrote:
> I want the files in a tar archive in sorted form. (Using GNU tar.)
> Either by date of the file or by its name (containing a number).
> For example I want these three files in sorted order like depicted:
> rfc748.txt
> rfc7168.txt
> rfc8774.txt
>
> I can add the files incrementally one by one to an empty archive,
> but I wanted to know whether there's a trick that I missed to fill
> the archive in one go, like tar cf sorted.tgz dir-with-files/
>
> On a quick search and man page inspection I couldn't see anything.

Here a quick man page inspection reveals:

“--sort=ORDER
When creating an archive, sort directory entries according
to ORDER, which is one of none, name, or inode.”

--
mrg

Re: tar files sort order by date or numeric name

<slrnt7aobl.1lo0.naddy@lorvorc.mips.inka.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5293&group=comp.unix.shell#5293

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: nad...@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Fri, 6 May 2022 17:57:09 -0000 (UTC)
Message-ID: <slrnt7aobl.1lo0.naddy@lorvorc.mips.inka.de>
References: <t53j3r$85d$1@dont-email.me>
Injection-Date: Fri, 6 May 2022 17:57:09 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="55041"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Fri, 6 May 2022 17:57 UTC

On 2022-05-06, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:

> I want the files in a tar archive in sorted form. (Using GNU tar.)
>
> I can add the files incrementally one by one to an empty archive,
> but I wanted to know whether there's a trick that I missed to fill
> the archive in one go, like tar cf sorted.tgz dir-with-files/

Various tar(1) implementations can read a list of files to archive.

$ ls | sort >list
$ tar -c -I list -f sorted.tar

GNU tar also supports this.

$ gtar -c -T list -f sorted.tar

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: tar files sort order by date or numeric name

<t54gqf$1fg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5294&group=comp.unix.shell#5294

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 7 May 2022 03:08:31 +0200
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <t54gqf$1fg$1@dont-email.me>
References: <t53j3r$85d$1@dont-email.me> <87mtfuk1cs.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 7 May 2022 01:08:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f4eb3ccd17a7795f17e39ec9ec42d113";
logging-data="1520"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18POzSMyF1EIdAakUh+WyR4"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:xuKBWWxNs5HFufUEsH05okJ/sko=
In-Reply-To: <87mtfuk1cs.fsf@axel-reichert.de>
 by: Janis Papanagnou - Sat, 7 May 2022 01:08 UTC

On 06.05.2022 19:38, Axel Reichert wrote:
> Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
>
>> I want the files in a tar archive in sorted form. (Using GNU tar.)
>> Either by date of the file or by its name (containing a number).
>> For example I want these three files in sorted order like depicted:
>> rfc748.txt
>> rfc7168.txt
>> rfc8774.txt
>>
>> I can add the files incrementally one by one to an empty archive,
>> but I wanted to know whether there's a trick that I missed to fill
>> the archive in one go, like tar cf sorted.tgz dir-with-files/
>
> I assume that something along
>
> ls -tr dir-with-files/ | xargs tar cf sorted.tgz
>
> is too brittle for you?

Too brittle? - Hmm.. - thinking about what happens if the arguments'
length will result in more than one call of tar triggered by xargs.
But I suppose using also the tar option to add to an existing archive
will solve that issue.

Thanks.

Janis

> Best regards
>
> Axel
>

Re: tar files sort order by date or numeric name

<t54h2j$2tn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5295&group=comp.unix.shell#5295

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 7 May 2022 03:12:51 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <t54h2j$2tn$1@dont-email.me>
References: <t53j3r$85d$1@dont-email.me>
<6275648d$0$454$65785112@news.neostrada.pl>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 7 May 2022 01:12:51 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f4eb3ccd17a7795f17e39ec9ec42d113";
logging-data="2999"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qWzjPmyXVWfkOAmqvZ8Xj"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:jBk7rDBlTkng0IRelIrAuO6ET/8=
In-Reply-To: <6275648d$0$454$65785112@news.neostrada.pl>
 by: Janis Papanagnou - Sat, 7 May 2022 01:12 UTC

On 06.05.2022 20:10, marrgol wrote:
> On 06/05/2022 at 18.41, Janis Papanagnou wrote:
>> I want the files in a tar archive in sorted form. (Using GNU tar.)
>> Either by date of the file or by its name (containing a number).
>> For example I want these three files in sorted order like depicted:
>> rfc748.txt
>> rfc7168.txt
>> rfc8774.txt
>>
>> I can add the files incrementally one by one to an empty archive,
>> but I wanted to know whether there's a trick that I missed to fill
>> the archive in one go, like tar cf sorted.tgz dir-with-files/
>>
>> On a quick search and man page inspection I couldn't see anything.
>
> Here a quick man page inspection reveals:
>
> “--sort=ORDER
> When creating an archive, sort directory entries according
> to ORDER, which is one of none, name, or inode.”

That's what I also had found in the man page, and none of the three
options will sort by date or by name with a numeric variable-length
numeric component. With 'name' the order would be
>> rfc7168.txt
>> rfc748.txt
>> rfc8774.txt
and with the other options arbitrary w.r.t. the stated requirement.

Janis

Re: tar files sort order by date or numeric name

<t54h3q$2tn$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5296&group=comp.unix.shell#5296

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 7 May 2022 03:13:30 +0200
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <t54h3q$2tn$2@dont-email.me>
References: <t53j3r$85d$1@dont-email.me>
<slrnt7aobl.1lo0.naddy@lorvorc.mips.inka.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 7 May 2022 01:13:30 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f4eb3ccd17a7795f17e39ec9ec42d113";
logging-data="2999"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19pvYXpARcKnzX/ySI9cwL2"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:N6lRZ5jLBvXo3DIXTxTHI0OiLeA=
In-Reply-To: <slrnt7aobl.1lo0.naddy@lorvorc.mips.inka.de>
 by: Janis Papanagnou - Sat, 7 May 2022 01:13 UTC

On 06.05.2022 19:57, Christian Weisgerber wrote:
> On 2022-05-06, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>
>> I want the files in a tar archive in sorted form. (Using GNU tar.)
>>
>> I can add the files incrementally one by one to an empty archive,
>> but I wanted to know whether there's a trick that I missed to fill
>> the archive in one go, like tar cf sorted.tgz dir-with-files/
>
> Various tar(1) implementations can read a list of files to archive.
>
> $ ls | sort >list
> $ tar -c -I list -f sorted.tar
>
> GNU tar also supports this.
>
> $ gtar -c -T list -f sorted.tar
>

I missed that. Thanks.

Janis

Re: tar files sort order by date or numeric name

<t54i7o$9r1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5297&group=comp.unix.shell#5297

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 7 May 2022 03:32:40 +0200
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <t54i7o$9r1$1@dont-email.me>
References: <t53j3r$85d$1@dont-email.me>
<6275648d$0$454$65785112@news.neostrada.pl> <t54h2j$2tn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 7 May 2022 01:32:40 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f4eb3ccd17a7795f17e39ec9ec42d113";
logging-data="10081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Gq8jRNAawX8JhIQ/uKCjf"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:TIP3HrWJnQi46G0H0x8Tc1pBamo=
In-Reply-To: <t54h2j$2tn$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 7 May 2022 01:32 UTC

On 07.05.2022 03:12, Janis Papanagnou wrote:
> On 06.05.2022 20:10, marrgol wrote:
>> On 06/05/2022 at 18.41, Janis Papanagnou wrote:
>>> I want the files in a tar archive in sorted form. (Using GNU tar.)
>>> Either by date of the file or by its name (containing a number).
>>> For example I want these three files in sorted order like depicted:
>>> rfc748.txt
>>> rfc7168.txt
>>> rfc8774.txt
>>>
>>> I can add the files incrementally one by one to an empty archive,
>>> but I wanted to know whether there's a trick that I missed to fill
>>> the archive in one go, like tar cf sorted.tgz dir-with-files/
>>>
>>> On a quick search and man page inspection I couldn't see anything.
>>
>> Here a quick man page inspection reveals:
>>
>> “--sort=ORDER
>> When creating an archive, sort directory entries according
>> to ORDER, which is one of none, name, or inode.”

I forgot to mention that this was the place where I'd have expected
some, say, --sort=mtime option variants. That way the call that I
currently use to create the tar file - I'm just tar'ing the directory
that contains the actual files - would stay simple and not require
xargs (incl. caveats) or separate file lists as suggested elsethread.
Needless to say, with the suggestions provided, it's just a matter of
convenience now, but maybe also a possible --sort extension candidate.

Janis

Re: tar files sort order by date or numeric name

<t555lb$1t3e$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5298&group=comp.unix.shell#5298

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!1kzjxob1apDgcOKlV0dflQ.user.46.165.242.75.POSTED!not-for-mail
From: bpat...@bellsouth.spamisicky.net (Brian Patrie)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 7 May 2022 02:04:10 -0500
Organization: an elaborate system of piles and accidents
Message-ID: <t555lb$1t3e$1@gioia.aioe.org>
References: <t53j3r$85d$1@dont-email.me>
<slrnt7aobl.1lo0.naddy@lorvorc.mips.inka.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62574"; posting-host="1kzjxob1apDgcOKlV0dflQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: Brian Patrie - Sat, 7 May 2022 07:04 UTC

Christian Weisgerber wrote:
> On 2022-05-06, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>
>> I want the files in a tar archive in sorted form. (Using GNU tar.)
>>
>> I can add the files incrementally one by one to an empty archive,
>> but I wanted to know whether there's a trick that I missed to fill
>> the archive in one go, like tar cf sorted.tgz dir-with-files/
>
> Various tar(1) implementations can read a list of files to archive.
>
> $ ls | sort >list
> $ tar -c -I list -f sorted.tar
>
> GNU tar also supports this.
>
> $ gtar -c -T list -f sorted.tar
>

You can also use "-T -" to read the list of files from stdin. So:

find dir-with-files | sort --version-sort \
| tar -czvf sorted.tgz --sort=none --no-recursion -T -

I'm abusing sort's "--version-sort" option to get the order that Janis
wants (beware that this will sort decimals incorrectly--i couldn't get
"--numeric-sort" to do the desired thing, for some unknown reason).
"--sort-none" tells tar not to do its own sorting. "--no-recursion"
tells tar not to do it's own directory diving--which would also muck
things up.

find (GNU findutils) 4.7.0-git
sort (GNU coreutils) 8.28
tar (GNU tar) 1.29

Re: tar files sort order by date or numeric name

<87fsllkdik.fsf@axel-reichert.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5299&group=comp.unix.shell#5299

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mai...@axel-reichert.de (Axel Reichert)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 07 May 2022 09:28:19 +0200
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <87fsllkdik.fsf@axel-reichert.de>
References: <t53j3r$85d$1@dont-email.me>
<slrnt7aobl.1lo0.naddy@lorvorc.mips.inka.de>
<t555lb$1t3e$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="9603a8ad0b0c013e19edb6178b4e1b19";
logging-data="30334"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ys4wwd1bBjJVvUrpyFvuGsEZW+8kdztI="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:pLMdNaohwkDR75eE0U+oV85loSE=
sha1:CJXWi71MReNiMjk2ZULhuCralGI=
 by: Axel Reichert - Sat, 7 May 2022 07:28 UTC

Brian Patrie <bpatrie@bellsouth.spamisicky.net> writes:

> You can also use "-T -" to read the list of files from stdin.

Ah, this avoids my xargs, great!

> find dir-with-files | sort --version-sort \
> | tar -czvf sorted.tgz --sort=none --no-recursion -T -

[...]

> "--sort-none" tells tar not to do its own sorting.

Would this be done otherwise, even though the files are given directly
on the command line as arguments (respectively read from STDIN) and not
created by globbing?

> "--no-recursion" tells tar not to do it's own directory diving

Is my understanding correct that this happens only if "find" returns
directories? So depending on the contents of Janis's "dir-with-files", a
simple

find dir-with-files -name "rfc*.txt"

might do, even without "-type f".

Best regards

Axel

Re: tar files sort order by date or numeric name

<t55t1b$hq$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5300&group=comp.unix.shell#5300

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 7 May 2022 15:43:07 +0200
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <t55t1b$hq$1@dont-email.me>
References: <t53j3r$85d$1@dont-email.me>
<slrnt7aobl.1lo0.naddy@lorvorc.mips.inka.de> <t555lb$1t3e$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 7 May 2022 13:43:07 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f4eb3ccd17a7795f17e39ec9ec42d113";
logging-data="570"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184EXvsKUJN3HL2B2nolePK"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:iT11S9Wnyi2iiWZMeYQHNNTgYdc=
In-Reply-To: <t555lb$1t3e$1@gioia.aioe.org>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 7 May 2022 13:43 UTC

On 07.05.2022 09:04, Brian Patrie wrote:
> Christian Weisgerber wrote:
>> On 2022-05-06, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>>
>>> I want the files in a tar archive in sorted form. (Using GNU tar.)
>>>
>>> I can add the files incrementally one by one to an empty archive,
>>> but I wanted to know whether there's a trick that I missed to fill
>>> the archive in one go, like tar cf sorted.tgz dir-with-files/
>>
>> Various tar(1) implementations can read a list of files to archive.
>>
>> $ ls | sort >list
>> $ tar -c -I list -f sorted.tar
>>
>> GNU tar also supports this.
>>
>> $ gtar -c -T list -f sorted.tar
>>
>
> You can also use "-T -" to read the list of files from stdin. So:
>
> find dir-with-files | sort --version-sort \
> | tar -czvf sorted.tgz --sort=none --no-recursion -T -
>
> I'm abusing sort's "--version-sort" option to get the order that Janis
> wants (beware that this will sort decimals incorrectly--i couldn't get
> "--numeric-sort" to do the desired thing, for some unknown reason).

With the 'sort' step I can use sort's -kn feature because of the
regularity of the file names in this case. Thanks.

Janis

> "--sort-none" tells tar not to do its own sorting. "--no-recursion"
> tells tar not to do it's own directory diving--which would also muck
> things up.
>
> find (GNU findutils) 4.7.0-git
> sort (GNU coreutils) 8.28
> tar (GNU tar) 1.29

Re: tar files sort order by date or numeric name

<83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5301&group=comp.unix.shell#5301

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!MVd6ZVLAlryQ4vKhGcyp9g.user.46.165.242.75.POSTED!not-for-mail
From: nn.throt...@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 07 May 2022 18:05:21 +0200
Organization: Aioe.org NNTP Server
Message-ID: <83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de>
References: <t53j3r$85d$1@dont-email.me>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Info: gioia.aioe.org; logging-data="27381"; posting-host="MVd6ZVLAlryQ4vKhGcyp9g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Mail-Copies-To: nobody
Cancel-Lock: sha1:pDl/KF6EO+MqF5JahCwSCZucW20=
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
X-Notice: Filtered by postfilter v. 0.9.2
 by: Helmut Waitzmann - Sat, 7 May 2022 16:05 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com>:
>I want the files in a tar archive in sorted form. (Using GNU tar.)
>Either by date of the file or by its name (containing a number).
>For example I want these three files in sorted order like depicted:
>rfc748.txt
>rfc7168.txt
>rfc8774.txt
>
>I can add the files incrementally one by one to an empty archive,
>but I wanted to know whether there's a trick that I missed to fill
>the archive in one go, like tar cf sorted.tgz dir-with-files/
>
>On a quick search and man page inspection I couldn't see anything.
>

The trick of a thorough inspection of the GNU tar info manual (not
just the manual page, but see the SEE ALSO section of the manual
page for how to get it), will reveal the options "--no-recursion",
"--null", and "--files-from", which you could use like in this
example to have the file names sorted by version number:

find dir-with-files/ -print0 |
sort --zero-terminated --version-sort |
tar cf sorted.tgz --no-recursion --null --files-from=-

A rule of thumb:  Whenever you want to gain more control of what
files in what order to be processed by GNU tar, use the
"--no-recursion", "--null", and "--files-from" options.  Let GNU
"find … -print0" collect the file names according to the given
criteria, then sort them using "sort --zero-terminated …" and
finally feed them to GNU tar.

If you want the file names to be sorted by their file contents
modification time, you could do

TZ=UTC0 find dir-with-files/ \
-printf '%TY %Tm-%TdT%TH:%TM:%TS %p\0' \
sort --zero-terminated -t ' ' -k 1,1n -k 2,2 -k 3 |
sed --zero-terminated -E -e '^/([[:graph:]]+ ){2}/s///' |
tar cf sorted.tgz --no-recursion --null --files-from=-

Let GNU find list the filenames, each of them prepended by its data
modification time, then let GNU sort sort the list of the filenames
by the prepended time stamps, then let GNU sed remove the prepended
timestamps from the filenames and finally feed them to GNU tar.

Thanks to the "-printf" GNU find predicate, the "--zero-terminated"
GNU sort and GNU sed options, and the "--null" GNU tar options that
will work with any filename.

Re: tar files sort order by date or numeric name

<t569tm$7b3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5302&group=comp.unix.shell#5302

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 7 May 2022 19:23:02 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <t569tm$7b3$1@dont-email.me>
References: <t53j3r$85d$1@dont-email.me>
<83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 7 May 2022 17:23:02 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f4eb3ccd17a7795f17e39ec9ec42d113";
logging-data="7523"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18smsQuFFXYgy8IX6r8AEeV"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:hi3jycnJDyj1YnGyrci3Dhb0Wh8=
In-Reply-To: <83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 7 May 2022 17:23 UTC

On 07.05.2022 18:05, Helmut Waitzmann wrote:
>
> If you want the file names to be sorted by their file contents
> modification time, you could do
>
> TZ=UTC0 find dir-with-files/ \
> -printf '%TY %Tm-%TdT%TH:%TM:%TS %p\0' \
> sort --zero-terminated -t ' ' -k 1,1n -k 2,2 -k 3 |
> sed --zero-terminated -E -e '^/([[:graph:]]+ ){2}/s///' |
> tar cf sorted.tgz --no-recursion --null --files-from=-

Thanks for you reply. The nice thing about Unix is that we can
construct solutions of arbitrary complexity solving (almost)
every imaginable task.

The task I have presented is quite primitive. With the previous
posts I think using something like sort -k1.4,1.7n as part of
a pipe serves quite well.

In my opinion, how files are inserted into a tar archive should
be controlled by tar options. That's why I'd still favor the
existence of some tar --sort=mdate feature[*] instead of more
or less complex workarounds. Being able to sort by numeric name
could also be an option.

It's certainly arguable whether tar should have an option --sort
instead of letting an external tool do the sort, but tar option
--sort is already there in GNU tar, so it would seem obvious to
complete the set of option arguments.

To put the pieces together; for now I think something along

ls rfcs/* | sort -t/ -k2.4,2.7n | tar czf rfcs.tgz -T -

(untested!) would serve me best.

Janis

[*] BTW, I noticed just now that the file dates turned out to be
not significant to indicate generation of the respective files,
so I will have to rely on the file name numbering in this case.

Re: tar files sort order by date or numeric name

<hT5d5amQFcDnGJM1l@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5303&group=comp.unix.shell#5303

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 7 May 2022 17:26:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <hT5d5amQFcDnGJM1l@bongo-ra.co>
References: <t53j3r$85d$1@dont-email.me> <83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 7 May 2022 17:26:01 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="63b00eb33d080773afa1f2890f392aa9";
logging-data="9081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zGf4uqCTucwE97P58vhLJ"
Cancel-Lock: sha1:Qk1TafAHxpW3umG2wKIROe3LLEE=
In-Reply-To: <83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de>
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Sat, 7 May 2022 17:26 UTC

On Sat, 07 May 2022 18:05:21 +0200
Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
> If you want the file names to be sorted by their file contents
> modification time, you could do
>
> TZ=UTC0 find dir-with-files/ \
> -printf '%TY %Tm-%TdT%TH:%TM:%TS %p\0' \
> sort --zero-terminated -t ' ' -k 1,1n -k 2,2 -k 3 |
> sed --zero-terminated -E -e '^/([[:graph:]]+ ){2}/s///' |
> tar cf sorted.tgz --no-recursion --null --files-from=-
>
> Let GNU find list the filenames, each of them prepended by its data
> modification time, then let GNU sort sort the list of the filenames
> by the prepended time stamps, then let GNU sed remove the prepended
> timestamps from the filenames and finally feed them to GNU tar.

For sorting using modification time it's simpler to do

find dir-with-files/ -printf '%T@ %p\0' |
sort -z -n -k1 |
gawk 'BEGIN { RS = "\0" } {print $2}' | etc.

> Thanks to the "-printf" GNU find predicate, the "--zero-terminated"
> GNU sort and GNU sed options, and the "--null" GNU tar options that
> will work with any filename.

Re: tar files sort order by date or numeric name

<835ymh595h.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5304&group=comp.unix.shell#5304

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!MVd6ZVLAlryQ4vKhGcyp9g.user.46.165.242.75.POSTED!not-for-mail
From: nn.throt...@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sat, 07 May 2022 23:23:54 +0200
Organization: Aioe.org NNTP Server
Message-ID: <835ymh595h.fsf@helmutwaitzmann.news.arcor.de>
References: <t53j3r$85d$1@dont-email.me>
<83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de>
<hT5d5amQFcDnGJM1l@bongo-ra.co>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Info: gioia.aioe.org; logging-data="37535"; posting-host="MVd6ZVLAlryQ4vKhGcyp9g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mail-Copies-To: nobody
Cancel-Lock: sha1:+T34xuN4vqjdS3ZF2rwMyl5jOuw=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Helmut Waitzmann - Sat, 7 May 2022 21:23 UTC

Spiros Bousbouras <spibou@gmail.com>:
>On Sat, 07 May 2022 18:05:21 +0200
>Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
>> If you want the file names to be sorted by their file contents
>> modification time, you could do
>>
>> TZ=UTC0 find dir-with-files/ \
>> -printf '%TY %Tm-%TdT%TH:%TM:%TS %p\0'
>
>For sorting using modification time it's simpler to do
>
> find dir-with-files/ -printf '%T@ %p\0' |

I considered using "%T@" but refrained from using it because of the
paragraph in the GNU find info manual:  "Below are the formats for
the directives '%A', '%C', and '%T', which print the file's
timestamps. Some of these formats might not be available on all
systems, due to differences in the C 'strftime' function between
systems."

The POSIX definition of the "strftime" function
(<https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html#top>)
knows the conversion specifiers "Y", "m", "d", "H", "M", and "S",
but not "@".

Re: tar files sort order by date or numeric name

<Nlz6LfePW2ZBvPV7I@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5305&group=comp.unix.shell#5305

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sun, 8 May 2022 06:10:09 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <Nlz6LfePW2ZBvPV7I@bongo-ra.co>
References: <t53j3r$85d$1@dont-email.me> <83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de> <hT5d5amQFcDnGJM1l@bongo-ra.co>
<835ymh595h.fsf@helmutwaitzmann.news.arcor.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 8 May 2022 06:10:09 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="00b7987619823a73846da9991bad6584";
logging-data="20112"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/OExourJb2JPe5WNJcV1H"
Cancel-Lock: sha1:3S9Bg2VLn5mJYWpB1wOwAa360r4=
In-Reply-To: <835ymh595h.fsf@helmutwaitzmann.news.arcor.de>
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Sun, 8 May 2022 06:10 UTC

On Sat, 07 May 2022 23:23:54 +0200
Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
> Spiros Bousbouras <spibou@gmail.com>:
> >On Sat, 07 May 2022 18:05:21 +0200
> >Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
> >> If you want the file names to be sorted by their file contents
> >> modification time, you could do
> >>
> >> TZ=UTC0 find dir-with-files/ \
> >> -printf '%TY %Tm-%TdT%TH:%TM:%TS %p\0'
> >
> >For sorting using modification time it's simpler to do
> >
> > find dir-with-files/ -printf '%T@ %p\0' |
>
> I considered using "%T@" but refrained from using it because of the
> paragraph in the GNU find info manual: "Below are the formats for
> the directives '%A', '%C', and '%T', which print the file's
> timestamps. Some of these formats might not be available on all
> systems, due to differences in the C 'strftime' function between
> systems."

The man page says

%Ak File's last access time in the format specified by k, which is
either `@' or a directive for the C `strftime' function. The pos-
sible values for k are listed below; some of them might not be
available on all systems, due to differences in `strftime' between
systems.

@ seconds since Jan. 1, 1970, 00:00 GMT, with fractional
part.

So the @ directive is on top of what strftime() offers.Note that
https://www.gnu.org/software/libc/manual/html_mono/libc.html#index-strftime
does not mention @ either. It does mention

%s

The number of seconds since the epoch, i.e., since
1970-01-01 00:00:00 UTC. Leap seconds are not counted
unless leap second support is available.

This format is a GNU extension.

but https://www.gnu.org/software/findutils/manual/html_mono/find.html does
not say you can use %s for seconds since the epoch.

> The POSIX definition of the "strftime" function
> (<https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html#top>)
> knows the conversion specifiers "Y", "m", "d", "H", "M", and "S",
> but not "@".

But POSIX does not mention --zero-terminated for sed or sort either.

Re: tar files sort order by date or numeric name

<87bkw8a3u8.fsf@axel-reichert.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5306&group=comp.unix.shell#5306

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mai...@axel-reichert.de (Axel Reichert)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sun, 08 May 2022 09:19:43 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <87bkw8a3u8.fsf@axel-reichert.de>
References: <t53j3r$85d$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4704555e2d4171a33b871c6aa0fe15c4";
logging-data="9643"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+itSou/SU3odE6ca56eQL4aWoshedYo88="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:vVcRBrucwB1wR5viSIc8josYZQQ=
sha1:Cxtvf7mpAHOIIS1HfdnLL8LSq2A=
 by: Axel Reichert - Sun, 8 May 2022 07:19 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

> I want the files in a tar archive in sorted form.

After the IMHO fruitful discussion I would like to ask why you want to
have them in sorted order in your tar file. I could not come up with a
motivation for this myself. Could you please explain?

Best regards

Axel

Re: tar files sort order by date or numeric name

<t57v04$6bc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5307&group=comp.unix.shell#5307

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sun, 8 May 2022 10:28:51 +0200
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <t57v04$6bc$1@dont-email.me>
References: <t53j3r$85d$1@dont-email.me> <87bkw8a3u8.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 8 May 2022 08:28:52 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9178e685eecfe84ebf3802e6b04c905c";
logging-data="6508"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18c9V+Gfvus7ffSWoxb1Enp"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:39NKKLCV1alcGECn7TWS2qNXCNI=
In-Reply-To: <87bkw8a3u8.fsf@axel-reichert.de>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sun, 8 May 2022 08:28 UTC

On 08.05.2022 09:19, Axel Reichert wrote:
> Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
>
>> I want the files in a tar archive in sorted form.
>
> After the IMHO fruitful discussion I would like to ask why you want to
> have them in sorted order in your tar file. I could not come up with a
> motivation for this myself. Could you please explain?

Sure. In short: sorted item lists let you find specific items or detect
inconsistencies easier on inspection or on comparison with other data.

If I inspect a foreign tar file I typically inspect the contents before
the decision of unpacking them or not. If I obtain a package with sorted
numbered items that are a subset of a larger set I can easily identify
whether a set of entities is in that package or not. It's just the usual
effect that sorted item lists let you identify specific items easier and
faster. The alternative for me with an unsorted archive would be to sort
the output of 'tar tvf' for that purpose. It's easier, though, to sort
it once when populating the archive than to require it be sorted by the
unpacking users many times. It's similar to, say, 'ls'; I don't want to
type 'ls | sort -whatever' every time to get an order where I can easily
spot what I am looking for. It may be just me (or few people) who prefer
data sorted, but since it doesn't cost me anything to provide it sorted
I decided to just do it that way.

BTW, the displayed (and sorted by date) items let me (in the course of
the discussion posts in this thread) recognize that the file's 'mtime'
isn't consistent with the file numbers order. So we can consider the
sorting also as a quality measure of data sets that helps finding bugs
or data inconsistencies easier.

And it's not only convenience for humans, also for computers/programs.
I recall that in the 1990's (when I was closer to programming than I am
now) we had sorted *.a (or *.so, don't recall) library archives. I don't
recall the technical details or the exact rationale, but the reason was
to increase the performance of the build process.

And, finally, for those who don't see an advantage of sorted data, let
me also point you to Donald Knuth's decade old book series "The Art of
Computer Programming" with the third book about "Sorting and Searching".
In the introduction he points to the "most important applications of
sorting"; a) Solving the "togetherness" problem, b) Matching items in
two or more files, and c) Searching for information by key values, that
closely resemble the reasons I had.

Janis

>
> Best regards
>
> Axel
>

%s in strftime(3) vs. %s in find(1) (Was: tar files sort order by date or numeric name)

<t584mm$3uijl$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5308&group=comp.unix.shell#5308

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: %s in strftime(3) vs. %s in find(1) (Was: tar files sort order by date or numeric name)
Date: Sun, 8 May 2022 10:06:14 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <t584mm$3uijl$1@news.xmission.com>
References: <t53j3r$85d$1@dont-email.me> <hT5d5amQFcDnGJM1l@bongo-ra.co> <835ymh595h.fsf@helmutwaitzmann.news.arcor.de> <Nlz6LfePW2ZBvPV7I@bongo-ra.co>
Injection-Date: Sun, 8 May 2022 10:06:14 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="4147829"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 8 May 2022 10:06 UTC

In article <Nlz6LfePW2ZBvPV7I@bongo-ra.co>,
Spiros Bousbouras <spibou@gmail.com> wrote:
....
>So the @ directive is on top of what strftime() offers.Note that
>https://www.gnu.org/software/libc/manual/html_mono/libc.html#index-strftime
>does not mention @ either. It does mention
>
> %s
>
> The number of seconds since the epoch, i.e., since
> 1970-01-01 00:00:00 UTC. Leap seconds are not counted
> unless leap second support is available.
>
> This format is a GNU extension.
>
>but https://www.gnu.org/software/findutils/manual/html_mono/find.html does
>not say you can use %s for seconds since the epoch.

I think the problem is that %s was already "taken" by "find" to mean
"size", so they couldn't use %s (from strftime) to mean seconds since the
epoch. So, they had to come up with something else (for "find" to use).

--
"Everything Roy (aka, AU8YOG) touches turns to crap."
--citizens of alt.obituaries--

Re: tar files sort order by date or numeric name

<871qx49uo9.fsf@axel-reichert.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5309&group=comp.unix.shell#5309

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mai...@axel-reichert.de (Axel Reichert)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sun, 08 May 2022 12:37:42 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <871qx49uo9.fsf@axel-reichert.de>
References: <t53j3r$85d$1@dont-email.me> <87bkw8a3u8.fsf@axel-reichert.de>
<t57v04$6bc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="8327d7b377d8b13df7b28daf161a8aac";
logging-data="23440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jhcQpWTkIJGyjlVcquXslhUZT1jbSq3c="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:nwtWDUtSBaNoZMTwUNXzGWFmPh8=
sha1:xEzwHvlqB9A1gUzSEA5DNLFQOvk=
 by: Axel Reichert - Sun, 8 May 2022 10:37 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

> sorted item lists let you find specific items or detect
> inconsistencies easier

Thanks. Spotting inconsistencies did not occur to me, although I have
often used sorting for this.

> It may be just me (or few people) who prefer data sorted

Me too, a habit passed on by my father. It also helps to find structure
in the data and thus, contrary to its bean-counting image might spark
creativity.

Best regards

Axel

Re: tar files sort order by date or numeric name

<83tua02o2i.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5310&group=comp.unix.shell#5310

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!i2pn.org!aioe.org!z4o1XKnex57ZdMqy0r1BUQ.user.46.165.242.75.POSTED!not-for-mail
From: nn.throt...@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Sun, 08 May 2022 14:42:13 +0200
Organization: Aioe.org NNTP Server
Message-ID: <83tua02o2i.fsf@helmutwaitzmann.news.arcor.de>
References: <t53j3r$85d$1@dont-email.me>
<83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de>
<hT5d5amQFcDnGJM1l@bongo-ra.co>
<835ymh595h.fsf@helmutwaitzmann.news.arcor.de>
<Nlz6LfePW2ZBvPV7I@bongo-ra.co>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Info: gioia.aioe.org; logging-data="5116"; posting-host="z4o1XKnex57ZdMqy0r1BUQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
X-Notice: Filtered by postfilter v. 0.9.2
Mail-Copies-To: nobody
Cancel-Lock: sha1:kOxHQAQmp/UMi9dBiFNhaYulIOc=
 by: Helmut Waitzmann - Sun, 8 May 2022 12:42 UTC

Spiros Bousbouras <spibou@gmail.com>:
> On Sat, 07 May 2022 23:23:54 +0200
> Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
>> Spiros Bousbouras <spibou@gmail.com>:
>>> On Sat, 07 May 2022 18:05:21 +0200
>>> Helmut Waitzmann <nn.throttle@xoxy.net> wrote:

>>>> If you want the file names to be sorted by their file contents
>>>> modification time, you could do
>>>>
>>>> TZ=UTC0 find dir-with-files/ \
>>>> -printf '%TY %Tm-%TdT%TH:%TM:%TS %p\0'
>>>
>>> For sorting using modification time it's simpler to do
>>>
>>> find dir-with-files/ -printf '%T@ %p\0' |
>>
>> I considered using "%T@" but refrained from using it because of
>> the paragraph in the GNU find info manual: "Below are the formats
>> for the directives '%A', '%C', and '%T', which print the file's
>> timestamps. Some of these formats might not be available on all
>> systems, due to differences in the C 'strftime' function between
>> systems."
>
> The man page says
>
> %Ak File's last access time in the format specified by k, which is
> either `@' or a directive for the C `strftime' function. The pos-
> sible values for k are listed below; some of them might not be
> available on all systems, due to differences in `strftime' between
> systems.
>
> @ seconds since Jan. 1, 1970, 00:00 GMT, with fractional
> part.
>
> So the @ directive is on top of what strftime() offers.
>

Strange.  I checked the manual page at my system (Debian buster)
and it's indeed the same as yours.  But the GNU find info manual at
my system says what I cited above.  The online GNU find info manual
(<https://www.gnu.org/software/findutils/manual/html_node/find_html/Time-Formats.html#Time-Formats>)
is even more clear:  "Below is an incomplete list of formats for
the directives ‘%A’, ‘%B’, ‘%C’, and ‘%T’, which print the file’s
timestamps.  Please refer to the documentation of strftime for the
full list.  Some of these formats might not be available on all
systems, due to differences in the implementation of the C strftime
function."

That is:  If a conversion specifier is not in the documentation of
the strftime function ("the full list"), then it will not be
available with GNU find.

So the info manuals disagree with the manual page.  Which one of
them is correct, which one is wrong?

Also, the manual page says (in the SEE ALSO section):  "The full
documentation for find is maintained as a Texinfo manual.  If the
info and find programs are properly installed at your site, the
command info find should give you access to the complete manual."

That lets me assume that the info manual is more complete than the
manual page.

In the BUGS section, the manual page says:  "The environment
variable LC_COLLATE has no effect on the -ok action." whereas in
the EXPRESSION and ENVIRONMENT VARIABLES sections it states that
the interpretation of the response given will be affected by the
environment variable LC_COLLATE.

Apparently the manual page contradicts itself.  That makes me doubt
of the reliability of it.  Perhaps it's a compilation of different
sources?

> Note that
> https://www.gnu.org/software/libc/manual/html_mono/libc.html#index-strftime
> does not mention @ either. It does mention
>
> %s
>
> The number of seconds since the epoch, i.e., since
> 1970-01-01 00:00:00 UTC. Leap seconds are not counted
> unless leap second support is available.
>
> This format is a GNU extension.
>
> but
> https://www.gnu.org/software/findutils/manual/html_mono/find.html
> does not say you can use %s for seconds since the epoch.

But since %s is neither part of the POSIX definition of the
strftime function nor part of the find info manual I refrained from
using it as well.

>> The POSIX definition of the "strftime" function
>> (<https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html#top>)
>> knows the conversion specifiers "Y", "m", "d", "H", "M", and "S",
>> but not "@".
>
> But POSIX does not mention --zero-terminated for sed or sort
> either.

As in the OP Janis stated that he is using GNU tar, I assumed he
might use GNU find, GNU sort, and GNU sed as well.  As he made no
statement about the strftime function at his system, I preferred to
be better safe than sorry.

Re: tar files sort order by date or numeric name

<t5c0ht$kgj$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5314&group=comp.unix.shell#5314

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!1kzjxob1apDgcOKlV0dflQ.user.46.165.242.75.POSTED!not-for-mail
From: bpat...@bellsouth.spamisicky.net (Brian Patrie)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Mon, 9 May 2022 16:19:57 -0500
Organization: an elaborate system of piles and accidents
Message-ID: <t5c0ht$kgj$1@gioia.aioe.org>
References: <t53j3r$85d$1@dont-email.me>
<slrnt7aobl.1lo0.naddy@lorvorc.mips.inka.de> <t555lb$1t3e$1@gioia.aioe.org>
<87fsllkdik.fsf@axel-reichert.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="21011"; posting-host="1kzjxob1apDgcOKlV0dflQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.1
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: Brian Patrie - Mon, 9 May 2022 21:19 UTC

Axel Reichert wrote:
> Brian Patrie <bpatrie@bellsouth.spamisicky.net> writes:
>
>> You can also use "-T -" to read the list of files from stdin.
>
> Ah, this avoids my xargs, great!
>
>> find dir-with-files | sort --version-sort \
>> | tar -czvf sorted.tgz --sort=none --no-recursion -T -
>
> [...]
>
>> "--sort-none" tells tar not to do its own sorting.
>
> Would this be done otherwise, even though the files are given directly
> on the command line as arguments (respectively read from STDIN) and not
> created by globbing?

It did for me.

>> "--no-recursion" tells tar not to do it's own directory diving
>
> Is my understanding correct that this happens only if "find" returns
> directories? So depending on the contents of Janis's "dir-with-files", a
> simple
>
> find dir-with-files -name "rfc*.txt"
>
> might do, even without "-type f".

Yes, "-type f" would probably solve the same problem, as
"--no-recursion", as long as no other types need to be caught, and you
don't need directory metadata in the archive (which may be desirable,
depending on the use case). It would be needed even without
subdirectories, as find will normally yield the specified dir in its output.

Re: tar files sort order by date or numeric name

<t5c24b$1815$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5315&group=comp.unix.shell#5315

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!1kzjxob1apDgcOKlV0dflQ.user.46.165.242.75.POSTED!not-for-mail
From: bpat...@bellsouth.spamisicky.net (Brian Patrie)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Mon, 9 May 2022 16:46:50 -0500
Organization: an elaborate system of piles and accidents
Message-ID: <t5c24b$1815$1@gioia.aioe.org>
References: <t53j3r$85d$1@dont-email.me>
<83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de> <t569tm$7b3$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="40997"; posting-host="1kzjxob1apDgcOKlV0dflQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: Brian Patrie - Mon, 9 May 2022 21:46 UTC

Janis Papanagnou wrote:
> To put the pieces together; for now I think something along
>
> ls rfcs/* | sort -t/ -k2.4,2.7n | tar czf rfcs.tgz -T -
>
> (untested!) would serve me best.

Just beware that subdirectories under rfcs/ may bugger things up. Also,
too many files might run you into the argv length limit (though that's
mighty huge, these days).

Re: tar files sort order by date or numeric name

<t5c3e8$j6t$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5316&group=comp.unix.shell#5316

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: tar files sort order by date or numeric name
Date: Tue, 10 May 2022 00:09:11 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <t5c3e8$j6t$1@dont-email.me>
References: <t53j3r$85d$1@dont-email.me>
<83czgp5nwe.fsf@helmutwaitzmann.news.arcor.de> <t569tm$7b3$1@dont-email.me>
<t5c24b$1815$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 9 May 2022 22:09:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ffdf3e4356649c5a5ada1032fa2391cb";
logging-data="19677"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197WsrH++miCNdzNkE7DTht"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:1SSuzdNdlo6xJP1DssSA3iRx6pg=
In-Reply-To: <t5c24b$1815$1@gioia.aioe.org>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Mon, 9 May 2022 22:09 UTC

On 09.05.2022 23:46, Brian Patrie wrote:
> Janis Papanagnou wrote:
>> To put the pieces together; for now I think something along
>>
>> ls rfcs/* | sort -t/ -k2.4,2.7n | tar czf rfcs.tgz -T -
>>
>> (untested!) would serve me best.
>
> Just beware that subdirectories under rfcs/ may bugger things up.

I don't have subdirectories, that's why I said it serves me best.

> Also,
> too many files might run you into the argv length limit (though that's
> mighty huge, these days).

Ah, right. I might then replace that code by

printf "%s\n" rfcs/* | sort -t/ -k2.4,2.7n | tar czf rfcs.tgz -T -

which (as a shell built-in) doesn't have that limit. (Or I can use
find, as suggested elsethread, though I prefer efficient built-ins.)

Janis

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor