[augeas-devel] Remove a value from an array with augtool?

Graham Leggett minfrin at sharp.fm
Sat Nov 24 13:08:38 UTC 2012


On 24 Nov 2012, at 9:19 AM, Raphaël Pinson <raphink at gmail.com> wrote:

> I can add a particular value to a given array with the set command, for example like this:
> 
> augtool> set /files/etc/postfix/main.cf/virtual_alias_maps[last()] my-map
> 
> 
> This will set the last element, even if it already exists. If you want to add an element to the array, you should use:
> 
>     set /files/etc/postfix/main.cf/virtual_alias_maps[last()+1] my-map
> 
> Note that this operation is not idempotent, it will add a new entry every time you run it.

Sorry you're right - that was a typo.
 
> 
> I am struggling with the syntax to remove this value "my-map" again:
> 
> augtool> rm [what-goes-here?]
> 
> 
> If you want to remove all virtual_alias_maps values, simply use:
> 
>     rm /files/etc/postfix/main.cf/virtual_alias_maps
> 
> If you only want to remove the last value:
> 
>     rm /files/etc/postfix/main.cf/virtual_alias_maps[last()] 

I don't want to remove the last value, I want to remove a specific value "my-map", which may appear anywhere in the array (the removal in my case will take place way after the addition, and other additions may have been made in the mean time).

Is there a way to reference the index of the array that contains that specific value, like this?

rm /files/etc/postfix/main.cf/virtual_alias_maps[(index-of-the-value-my-map)]

Regards,
Graham
--

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20121124/d7dc6fdf/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4365 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20121124/d7dc6fdf/attachment.p7s>


More information about the augeas-devel mailing list