Skip to content

Instantly share code, notes, and snippets.

@nickanderson
Last active July 7, 2023 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickanderson/287bf23c82db1aa7c62d561e9111aecb to your computer and use it in GitHub Desktop.
Save nickanderson/287bf23c82db1aa7c62d561e9111aecb to your computer and use it in GitHub Desktop.
Example illustrating use of regex_replace() to remove quiet from GRUB_CMDLINE_LINUX_DEFAULT

Example illustrating use of regex_replace() to remove quiet from GRUB_CMDLINE_LINUX_DEFAULT

Use regex_replace() to remove quiet from GRUB_CMDLINE_LINUX_DEFAULT.

bundle agent __main__
{
    methods:
     "init";
     "test";
}
bundle agent init
{
    files:
      "/tmp/test.txt"
        content => 'GRUB_CMDLINE_LINUX_DEFAULT="hobgoblin quiet splash bobgoblin"';
}
bundle agent test
{
   files:
      "/tmp/test.txt"
        content => regex_replace( readfile( "/tmp/test.txt", inf ),
                                  '^(GRUB_CMDLINE_LINUX_DEFAULT=".*)quiet(.*")', "\1\2", "");

   reports:
      "/tmp/test:" printfile => cat( "/tmp/test.txt" );

}
    info: Updated file '/tmp/test.txt' with content 'GRUB_CMDLINE_LINUX_DEFAULT="hobgoblin quiet splash bobgoblin"'
    info: Updated file '/tmp/test.txt' with content 'GRUB_CMDLINE_LINUX_DEFAULT="hobgoblin  splash bobgoblin"'
R: /tmp/test:
R: GRUB_CMDLINE_LINUX_DEFAULT="hobgoblin  splash bobgoblin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment