On Wed, Mar 16, 2011 at 07:56:41PM +0000, Joseph L. Casale wrote: > I am trying to deduce the one liner for an rpm I am packaging to edit a php > configuration file from within my spec. The line I am editing looks like: > > $conf['nagios_base'] = "/nagios/cgi-bin"; > > What are the escape requirements Perl needs from within the shell to > search for this? > > As I have seen, the syntax is a mess, any pointers would be appreciated! Go easy on yourself, and : a) don't try to match the quotation marks verbatim. Instead, match them with simply a . b) use parenthesis to 'remember' a pattern that you don't want to have to specify again. E.g. to replace the path on the right-hand-side, do this: (i replaced it with a /; you could of course replace it with whatever you want) perl -i -ne 's/(^\s*\$conf\[.nagios_base.] = ).\/nagios\/cgi-bin.;/$1 \"\/\";/; print;' phpConfigFileName E.g. to delete the line outright: perl -i -ne 'print unless /^\s*\$conf\[.nagios_base.] = .\/nagios\/cgi-bin.;/;' phpConfigFileName Cheers, Jon