From: zzapper <zsh@rayninfo.co.uk>
To: zsh-users@zsh.org
Subject: Re: Append newline to many files
Date: Mon, 26 Sep 2022 09:11:04 +0100 [thread overview]
Message-ID: <807cfc5a-78e0-d74f-160c-f68d2c463997@rayninfo.co.uk> (raw)
In-Reply-To: <CAN=4vMryQFVz4kckKqVtT=L-nXFrY_i7X-67RywLPYF7XDF-Hw@mail.gmail.com>
On 25/09/2022 14:30, Roman Perepelitsa wrote:
> On Sun, Sep 25, 2022 at 3:21 PM Dominik Vogt <dominik.vogt@gmx.de> wrote:
>> Assume there are thousands of text files that are not terminated
>> with a newline. I want to concatenate them all, but add the
>> missing newline between files.
>>
>> This works but takes ten times as much time as "cat foo.*".
>>
>> for i in foo.*; do cat "$i"; echo; done > out
>>
>> I can't really think of a fast yet simple solution.
> This should work:
>
> print >lf
> files=(foo.*)
> lf=(lf)
> cat -- ${files:^^lf}
> rm lf
>
> Roman.
>
This looks interesting but any chance of an explanation of how it works
for us lesser mortals please?
zzapper
next prev parent reply other threads:[~2022-09-26 8:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-25 13:19 Dominik Vogt
2022-09-25 13:30 ` Roman Perepelitsa
2022-09-26 8:11 ` zzapper [this message]
2022-09-26 8:51 ` Dominik Vogt
2022-09-26 19:39 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=807cfc5a-78e0-d74f-160c-f68d2c463997@rayninfo.co.uk \
--to=zsh@rayninfo.co.uk \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).