Skip to content

Instantly share code, notes, and snippets.

@raphink
Last active August 29, 2015 13:56
Show Gist options
  • Save raphink/9278926 to your computer and use it in GitHub Desktop.
Save raphink/9278926 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use Config::Augeas;
use warnings;
use strict;
my $aug_root = '/home/rpinson/bas/augeas';
my $aug = Config::Augeas->new(root => $aug_root);
$aug->set('/augeas/load/Simplelines/incl[last()+1]', '/users');
$aug->load();
# Define a variable called $nomatches which points to /files/users only if user "shanw" is not present
$aug->defvar(nomatches => '/files/users[count(*[.="shanw"])=0]');
# This won't do anything if $nomatches doesn't point to the file
$aug->set('$nomatches/01', 'shanw');
$aug->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment