bug-bash
[Top][All Lists]
Advanced

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

RE: Backquote Mystery


From: Com MN PG P E B Consultant 3
Subject: RE: Backquote Mystery
Date: Thu, 23 Mar 2006 16:46:11 +0100

 

> 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




reply via email to

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