> Try echo "$e". Then read about Word Splitting in the Bash manual.
Good point. Since no word splitting occurs within "$e", it is
expanded to a string containing newlines:
$ echo $e # Expansion without quotes -> word splitting
x sub: f
$ echo "$e" # Expansion with quotes -> no word splitting
x
sub:
f
grep then matches the empty line. Indeed, one can reproduce this
with a much simpler example:
$ u=$(printf 'ab\n\ncd\n')
$ echo xx|grep "$u"
xx
So we don't have a mystery here, but rather an undocumented feature
of grep (or at least not documented in the man pages of *my*
version of grep): If the pattern is a string containing newline
characters, grep matches each of these lines in order to every line
in the input file, until a match is found.
Thank you for pointing me into the right direction.
Ronald
--
Ronald Fischer (phone +49-89-63676431)
mailto:mn-pg-p-e-b-consultant-3.com@siemens.com