perl or sed s/// problem
Matt Graham
danceswithcrows at usa.net
Thu Aug 5 11:07:47 MST 2010
From: David <david at damnetwork.net>
> line="password requisite /lib/security/$ISA/pam_cracklib.so
> newline="password required /lib/security/$ISA/pam_cracklib.so
> I need to maintain whitespace
>
> perl -p -i -e s/"$line"/"$newline"/ file
>
> That tosses out all kinds of errors
Modern regexp engines allow you to use an arbitrary char as the pattern
delimiter. If I've got slashes in my patterns, I tend to use # as the
delimiter, which allows you to avoid Leaning Toothpick Syndrome. Other people
may use | . # is visually distinctive and not as common as / in some
string-replace contexts, though:
perl -p -i -e 's#"$line"#"$newline"#' file
--
Matt G / Dances With Crows
The Crow202 Blog: http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see
More information about the PLUG-discuss
mailing list