[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed: dot does not match newline in multi-line mode (the M modifier)
From: |
Thierry Blanc |
Subject: |
Re: sed: dot does not match newline in multi-line mode (the M modifier) - bug or feature? |
Date: |
Wed, 23 Nov 2011 19:09:44 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111110 Thunderbird/8.0 |
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 ..
address@hidden:~/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
address@hidden:~/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
address@hidden:~/sed$ echo $'line1\nline2\nline3' | sed -n
'1h;1!H;$bend;b; :end g;s/\`/BEGINofBUFFFER:/m;p'
BEGINofBUFFFER:line1
line2
line3
address@hidden:~/sed$ echo $'line1\nline2\nline3' | sed -n
'1h;1!H;$bend;b; :end g;s/'"\'"'/:ENDofBUFFFER/m;p'
line1
line2
line3:ENDofBUFFFER