Hi Dan,
You're not too far. You just missing the right operator for `regexp()`: https://github.com/hercules-team/augeas/wiki/Path-expressions#tips--tricks /files/etc/hosts/*[ipaddr =~ regexp("192\..*")] Raphaël On Sat, Nov 14, 2020 at 10:39 PM Dan Mahoney (Gushi) <[email protected]> wrote: > All, > > We're trying at the day job to use Augtool to clean up some > in-the-os-by-default comments. Under FreeBSD, this is what you might find > in a stock /etc/pam.d/sshd: > > match /files/etc/pam.d/sshd/* > /files/etc/pam.d/sshd/#comment[1] = $FreeBSD: releng/11.4/etc/pam.d/sshd > 197769 2009-10-05 09:28:54Z des $ > /files/etc/pam.d/sshd/#comment[2] = PAM configuration for the "sshd" > service > /files/etc/pam.d/sshd/#comment[3] = auth > /files/etc/pam.d/sshd/1 = (none) > /files/etc/pam.d/sshd/2 = (none) > /files/etc/pam.d/sshd/#comment[4] = auth sufficient > pam_krb5.so no_warn try_first_pass > /files/etc/pam.d/sshd/#comment[5] = auth sufficient > pam_ssh.so no_warn try_first_pass > /files/etc/pam.d/sshd/3 = (none) > /files/etc/pam.d/sshd/#comment[6] = account > /files/etc/pam.d/sshd/4 = (none) > /files/etc/pam.d/sshd/#comment[7] = account required pam_krb5.so > /files/etc/pam.d/sshd/5 = (none) > /files/etc/pam.d/sshd/6 = (none) > /files/etc/pam.d/sshd/#comment[8] = session > /files/etc/pam.d/sshd/#comment[9] = session optional pam_ssh.so > want_agent > /files/etc/pam.d/sshd/7 = (none) > /files/etc/pam.d/sshd/#comment[10] = password > /files/etc/pam.d/sshd/#comment[11] = password sufficient pam_krb5.so > no_warn try_first_pass > /files/etc/pam.d/sshd/8 = (none) > > And what I can't seem to find out how to do is match comments by name. For > example, if I wanted to match any (or delete) any comment that include > pam_krb5, how would I do it? > > As a comment, the usual parsing rules don't apply, and in all the wiki > docs I can't find a clean example about "This is how you match a string by > name". (Call this a docbug maybe?) > > Help? > > -Dan > > PS, here's some of the things I've been trying -- am I just barking up the > wrong tree here? > > augtool> match /files/etc/pam.d/sshd/#comment[ value = freebsd ] > (no matches) > augtool> match /files/etc/pam.d/sshd/#comment[ value = "freebsd" ] > (no matches) > augtool> match /files/etc/pam.d/sshd/#comment[ value() = "freebsd" ] > error: Invalid path expression > error: empty name > /files/etc/pam.d/sshd/#comment[ |=|value() = "freebsd" ] > augtool> match /files/etc/pam.d/sshd/#comment[ value = regex("freebsd") ] > error: Invalid path expression > error: empty name > /files/etc/pam.d/sshd/#comment[ value = |=|regex("freebsd") ] > augtool> match /files/etc/pam.d/sshd/#comment[ value = regexp("freebsd") ] > error: Invalid path expression > error: type error > /files/etc/pam.d/sshd/#comment[ value = regexp("freebsd") ]|=| > augtool> match /files/etc/pam.d/sshd/#comment[ value = regexp("freebsd") ] > error: Invalid path expression > error: type error > /files/etc/pam.d/sshd/#comment[ value = regexp("freebsd") ]|=| > augtool> match /files/etc/pam.d/sshd/#comment[ regexp("freebsd") ] > error: Invalid path expression > error: type error > /files/etc/pam.d/sshd/#comment[ regexp("freebsd") ]|=| > augtool> match /files/etc/pam.d/sshd/#comment[ regexp(freebsd) ] > error: Invalid path expression > error: type error > /files/etc/pam.d/sshd/#comment[ regexp(freebsd) ]|=| > augtool> match /files/etc/pam.d/sshd/#comment[ regexp(/freebsd/) ] > error: Invalid path expression > error: empty name > > > -- > > --------Dan Mahoney-------- > Techie, Sysadmin, WebGeek > Gushi on efnet/undernet IRC > FB: fb.com/DanielMahoneyIV > LI: linkedin.com/in/gushi > Site: http://www.gushi.org > --------------------------- > > _______________________________________________ > augeas-devel mailing list > [email protected] > https://www.redhat.com/mailman/listinfo/augeas-devel > > -- Raphaël Pinson Infrastructure Developer & Training Leader +41 21 619 10 65 Camptocamp SA EPFL Innovation Park, Bât A 1015 Lausanne www.camptocamp.com
_______________________________________________ augeas-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/augeas-devel
