note
ikegami
<p>First, don't forget to escape @ and ..</p>
<code>
>perl -lne "/^root:\s*(?!admin\@somewhere\.here)(.*)/ and print $1" \
aliases.txt
someone@somewhere.else
admin@somewhere.here
</code>
<p>Note the leading space. When the regexp engine failed using all the spaces, it backtracked to \s* matching all but one space. One way to fix it is to anchor it as follows:</p>
<code>
>perl -ne "/^root:\s*(?!admin\@somewhere\.here)\S/ and print;" \
aliases.txt
root: someone@somewhere.else
</code>
390074
390074