Subject: bug#22568: "grep ... | tee file" drops the 'n' in its output

From: Eric Blake <[email-masked]>
Date: Fri, 5 Feb 2016 15:05:24 -0700

On 02/05/2016 02:41 PM, oldefoxx wrote:
> Odd problem.  Seems to be partly tied to when IFS=\n is used for

You didn't provide enough context for us to see what you were actually
typing.  But if you really typed:

IFS=\n
....stuff....

then that's the same as if you had typed:

IFS=n

which tells the shell to treat 'n' (and only 'n') as the character to
use during word splitting.  And that's a rather unusual use of IFS.

Did you mean to type:

IFS=$'\n'

as a way to limit IFS to just newlines?  Compared to the usual default
IFS of $' \t\n'?

> handling read statements.  Can't find a way around it that works
> reliably, so forced to use
>     grep  ... > file; cat file

It's not obvious how grep, cat, or tee fit into the picture here.
Without seeing the full shell script you are running, it is very hard to
say what exactly went wrong for you, but in all likelihood, it is NOT a
bug in 'tee' nor in 'grep', but a case of the shell doing exactly what
you told it to.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org