On Fri, Apr 29, 2011 at 02:05:31PM -0400, no-re...@cfengine.com wrote: >Forum: Cfengine Help >Subject: regex help >Author: neilhwatson >Link to topic: https://cfengine.com/forum/read.php?3,21705,21705#msg-21705 > >I have a line that I want to insert into a file. I also want to remove any >other permutations of that line from the file. Appending is easy deleting >without deleting the correct line is a challenge. I've tried some lookaheads >and lookbehinds but I'm not very good with these types of regular expressions. > This is the correct line > >00 3 1 * * /usr/scripts/util/distributed-multipath-ck.sh 2>&1 > /dev/null > >This is the regext to remove the unwanted lines > >(?<!00 3 1 \* \*)\s*/usr/scripts/util/distributed-multipath-ck.sh\s*(?!2>&1 > >/dev/null) ^^^^^ Do you want to use \s+ here?
>Here is the target file > >45 * * * * /var/cfengine/bin/cf-execd -F > /dev/null 2>&1 || >/usr/local/sbin/cf-failsafe.sh >01 3 1 * * /usr/scripts/util/distributed-multipath-ck.sh 2>&1 > /dev/null >15 00 * * * logger -p local0.notice `uname -n`:l0gg3r >0 7 1 * * /usr/scripts/util/lsa > /dev/null 2>&1 >00 3 1 * * /usr/scripts/util/distributed-multipath-ck.sh 2>&1 > /dev/null > > >My goal is that line two should be removed because it is an unwanted >permutation of the desired shell script. I suspect the problem is with the >negative look behind but I don't how to fix it. > >_______________________________________________ >Help-cfengine mailing list >Help-cfengine@cfengine.org >https://cfengine.org/mailman/listinfo/help-cfengine -- Jesse Becker NHGRI Linux support (Digicon Contractor) _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine