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: Brendan Strejcek
Subject: Re: editfiles and replacing on one line
Date: Sun, 6 Nov 2005 18:28:39 -0600
User-agent: Mutt/1.5.6+20040818i

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
    }

Best,
Brendan

--
Senior System Administrator
The University of Chicago
Department of Computer Science
http://www.cs.uchicago.edu/people/brendan




reply via email to

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