[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: non-convergent file edit?
From: |
Mark . Burgess |
Subject: |
Re: non-convergent file edit? |
Date: |
Tue, 16 Mar 2004 17:09:24 +0100 (MET) |
ReplaceOnce cannot be implemented, since you don't know what you did last
time, next time if you get my drift.
M
On 16 Mar, rader@ginseng.hep.wisc.edu wrote:
>
> > > Assume...
> > >
> > > echo "01Jan70" > f
> > >
> > > then is there a way to do
> > >
> > > mv f f.OLD && \
> > > cat f.OLD | perl -ne "s/\d\d\w\w\w\d\d/`date +%d%h%y`/; print" > f && \
> > > rm f.OLD
> > >
> > > with editfiles??
> > >
> > > Just curious. Using shellcommands is a reasonable solution.
>
> > From: Chris Edillon
> > you could do something like this:
> >
> > any::
> > { /tmp/f
> > ReplaceAll "[[:digit:]]{2}[[:alpha:]]{3}[[:digit:]]{2}" With
> > "$(day)$(month)$(year)"
> > }
> >
> > but cfagent will complain that it is non-convergent since the string
> > you'd put in place will always match the regex so it will get re-edited
> > every run. if you know that all of the date strings in question are
> > of a certain year or have some other static characteristic you could
> > put in the regex, it might work.
>
> Yeah, I played around with that. The replacement string is the
> same length as the regex and matches the regex, so the substitution
> non-convergent... like saying in perl terms...
>
> $a = "A 01Jan70 B 01Jan70 C";
> $b = "16Mar04";
> while ( $a =~ /\d\d\w\w\w\d\d/ ) {
> $a =~ s/\d\d\w\w\w\d\d/$b/;
> print "oops!\n";
> }
>
> Seems to me (a cfengine novice) that ReplaceAll should behave like
> s/regex/newstr/g (magically converge?) or maybe there should be
>
> ReplaceOnce regex With newstr
>
> steve
> - - -
> systems & network guy
> high energy physics
> university of wisconsin
>
>
>
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272 Email: Mark.Burgess@iu.hio.no
Fax : +47 22453205 WWW : http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: non-convergent file edit?, Brendan Strejcek, 2004/03/18