We've expanded our news coverage and improved our search! Visit
oreilly.com for the latest or search for all things across O'Reilly!
| 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...
|