ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Hack:   Global Search and Replace with Perl
Subject:   (\s+)? versus (\s)*
Date:   2003-12-15 20:51:04
From:   anonymous2
Response to: (\s+)? versus (\s)*

the obvious difference is in the results ...


perl -pi -e 's/^(\s+)?(telnet|shell|login|exec)/# $2/' /etc/inetd.conf


will remove any leading whitespace before "telnet" or "shell" or ...


whereas


perl -pi -e 's/^(\s)*(telnet|shell|login|exec)/# $2/' /etc/inetd.conf


Would presumably replace the line with the second whitespace charecter, if there was one...