perl or sed s/// problem

Lisa Kachold lisakachold at obnosis.com
Thu Aug 5 11:07:39 MST 2010


Hi David:

On Thu, Aug 5, 2010 at 10:44 AM, David <david at damnetwork.net> wrote:

>
> I'm having a problem with perl *and* sed with a particular replace line.
>  The lines I'm trying to search for, and replace, both have "/" characters,
> which is completely killing me.
>
> line="password    requisite     /lib/security/$ISA/pam_cracklib.so retry=3"
> newline="password required /lib/security/$ISA/pam_cracklib.so minlen=8
> dcredit=-1 ucredit=-1 lcredit=0 minclass=3  retry=3"
>

Escape any special regexp characters with \

line="password requisite \/lib\/security\/$ISA\/pam_
>
> cracklib.so retry=3"
> newline="

password requisite \/lib\/security\/$ISA\/pam_
>
> cracklib.so retry=3


 See the following guide reference:

http://www.anaesthetist.com/mnm/perl/Findex.htm

I need to maintain whitespace, too.
>

perl -pi.bak -e 's/password requisite \/lib\/security\/$ISA\/pam_cracklib.so
retry=3/password requisite \/lib\/security\/$ISA\/pam_cracklib.so
retry=3/g'  file

>
> You might just type out the value of $ISA also -- it's a "special
character" also (I would).



> That tosses out all kinds of errors, since perl believes the first "/lib"
> line to be the next delimiter.  Even using the magical \Q and \E things
> doesn't work.  AARRGGHH!!!
>
> Sed seems to have the same problem.   Anyone have any ideas on how I can
> get this to work?  And yes, unfortunately, I need to use the variables.
>
>
So, I know this was not the type of perl "quote" help you wanted....but it's
worth noting:

http://xkcd.com/208/



> Thanks,
> David
>

<>time



> --
> "I find your lack of faith disturbing."
> --Darth Vader
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>



-- 
Office: (602)239-3392
AT&T: (503)754-4452

"Faith is, at one and the same time, absolutely necessary and altogether
impossible. "
--Stanislav Lem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20100805/427180ea/attachment.html>


More information about the PLUG-discuss mailing list