Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Append newline to many files
- X-seq: zsh-users 28125
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: dominik.vogt@xxxxxx, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Append newline to many files
- Date: Sun, 25 Sep 2022 15:30:12 +0200
- Archived-at: <https://zsh.org/users/28125>
- In-reply-to: <YzBVdjtkqpXnGkvK@gmx.de>
- List-id: <zsh-users.zsh.org>
- References: <YzBVdjtkqpXnGkvK@gmx.de>
On Sun, Sep 25, 2022 at 3:21 PM Dominik Vogt <dominik.vogt@xxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author