help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: editfiles and replacing on one line


From: Viraj Alankar
Subject: Re: editfiles and replacing on one line
Date: Sun, 6 Nov 2005 21:07:11 -0500

Thanks. So I guess there is no way if I don't know what the exact line
will look like? Basically I could do a 'perl -pie' but was hoping I
could do it within cfengine.

Viraj.

On 11/6/05, Brendan Strejcek <brendan@cs.uchicago.edu> wrote:
> Viraj Alankar wrote:
>
> > ...
> > /dev/sda2               /tmp                    ext3
> > defaults,nosuid,nodev,noexec        1 2
> > ...
> >
> > I would like to remove ',noexec' from this line only. I thought of
> > using LocateLineMatching to find the line, but am not sure how to do
> > the replacement.
>
> Here is a very careful way to do it, though it requires that you know
> the entire form of the line you want to end up with.
>
> control:
>     fstab_line = ( "/dev/sda2 /tmp ext3 defaults,nosuid,nodev 1 2" )
>
> editfiles:
>     { /etc/fstab
>         AppendIfNoSuchLine "${fstab_line}"
>         ResetSearch "1"
>         LocateLineMatching "^/dev/sda2.*$"
>         BeginGroupIfNoMatch "^${fstab_line}$"
>             ReplaceLineWith "${fstab_line}"
>         EndGroup
>         DeleteLinesAfterThisMatching "^/dev/sda2.*$"
>         CatchAbort
>     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]