I want to do something along the lines of:

set /files/etc/exports/dir[. = '/export/home'][client = ''] /export/home
set /files/etc/exports/dir[. = '/export/home'][client = '']/client

What happens if I run the above is that the second command creates yet another new node, without any dir value set. My challenge is that /export/home share is not a unique dir, as clients are added on new lines for readability. I need both dir and client search options to find a unique node.

How can I reference the (maybe) newly created node in command 1, such that the end result is:


Augeas have something called defnode which do a set command and store the resulting node in the variable specified.

Solution to my problem:

defnode newdir /files/etc/exports/dir[. = '/export/home' and client = ''] /export/home
set $newdir/client
set $newdir/client/option[1] rw
set $newdir/client/option[2] async
set $newdir/client/option[3] no_subtree_check

*Edit: Changed ][ to and for better readability

| improve this answer | |
  • 1
    That is indeed the best option. As a note, it is better to use [a and b] than [a][b]. – ℝaphink Nov 26 '13 at 17:51
  • It's not only a matter of readability, it's a different logic. [a][b] selects first the nodeset that matches [a], and then selects another sub-nodeset from it that matches [b]; while [a and b] only does one matching, on the [a and b] condition. – ℝaphink Dec 3 '13 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.