coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tee: add --remove-cr option


From: Nikos Papaspyrou
Subject: Re: tee: add --remove-cr option
Date: Wed, 9 Feb 2022 10:28:16 +0100

On Wed, Feb 9, 2022 at 9:14 AM Nikos Papaspyrou <nikolaos@google.com> wrote:
>
> On Wed, Feb 9, 2022 at 8:30 AM Bernhard Voelker
> <mail@bernhard-voelker.de> wrote:
> >
> > > More specifically, lines ending with carriage return are sent to the
> > > standard output but not to the files.
> >
> > -1
> > IMO it's not tee(1)'s business to modify the content it is streaming.
>
> This is a fair comment and in principle I can only agree. However, if the
> intended behavior is to send something different to the LOG file from what
> goes to the standard output, there's no easy way to obtain it unless sed
> implements it.

On second thought, with the proposed option:

  $ tee --remove-cr FILE1 FILE2 ...

is equivalent to:

  $ tee >(remove-cr > FILE1) >(remove-cr > FILE2) ...

where remove-cr is a filter that does:

  $ sed 's/\r/@REMOVE\n/g' | sed '/@REMOVE$/d'

That shouldn't be hard to automate, so if you insist on keeping tee's
purity, I'll happily withdraw the proposal.

If anybody wants this in a native executable for performance reasons,
my patch is there. It also applies the filter just once, in case of
multiple files, compared to the above.

-- 
Nikolaos Papaspyrou
Software Engineer
nikolaos@google.com

Google Germany GmbH
Erika-Mann-Strasse 33
80636 Muenchen

Geschaeftsfuehrer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Diese E-Mail ist vertraulich. Falls Sie diese faelschlicherweise
erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes
weiter, loeschen Sie alle Kopien und Anhaenge davon und lassen Sie
mich bitte wissen, dass die E-Mail an die falsche Person gesendet
wurde.

This e-mail is confidential. If you received this communication by
mistake, please don't forward it to anyone else, please erase all
copies and attachments, and please let me know that it has gone to the
wrong person.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]