Re: sed: dot does not match newline in multi-line mode (the M modifier) - bug or feature?
Thierry Blanc <[email protected]>
| Newsgroups | gmane.editors.sed.user,gmane.comp.gnu.utils.bugs |
|---|---|
| Message-ID | <[email protected]> |
On 11/23/2011 05:36 PM, Paolo Bonzini wrote:
> echo $'line1\nline2\nline3' | sed -n '1h;1!H;$bend;b; :end g;s/.*/dot
> > matches newline/;p; g;s/.*/dot does not match newline/M;p'
`M'
`m'
The `M' modifier to regular-expression matching is a GNU `sed'
extension which causes `^' and `$' to match respectively (in
addition to the normal behavior) the empty string after a newline,
and the empty string before a newline. There are special character
sequences (`\`' and `\'') which always match the beginning or the
end of the buffer. `M' stands for `multi-line'.
the M or m option seems to match also ..
ith@ith-laptop:~/sed$ echo $'line1\nline2\nline3' | sed -n
'1h;1!H;$bend;b; :end g;s/^/dot matches newline/M;p'
dot matches newlineline1
line2
line3
ith@ith-laptop:~/sed$ echo $'line1\nline2\nline3' | sed -n
'1h;1!H;$bend;b; :end g;s/$/dot matches newline/M;p'
line1dot matches newline
line2
line3
ith@ith-laptop:~/sed$ echo $'line1\nline2\nline3' | sed -n
'1h;1!H;$bend;b; :end g;s/\`/BEGINofBUFFFER:/m;p'
BEGINofBUFFFER:line1
line2
line3
ith@ith-laptop:~/sed$ echo $'line1\nline2\nline3' | sed -n
'1h;1!H;$bend;b; :end g;s/'"\'"'/:ENDofBUFFFER/m;p'
line1
line2
line3:ENDofBUFFFER
[Non-text portions of this message have been removed]