1 Reply Latest reply: Jan 1, 2014 10:55 PM by Catch_22 RSS

    grep with variable

    salmi_oraDev

      HI

       

      I am writing a script in which I use the grep command lookaround to get the value of a kernel parameter like this

      grep -Po '(?<= kernel.shmmni =).*  /etc/sysctl.conf

       

      Instead of writing the same commande for all kernel parameter I want to use a function in which I want to use the grep command like this

       

      grep -Po '(?<= var ).*  /etc/sysctl.conf

       

      var: is parameter of the fucnction

       

      How can I do it ?

       

      Regards.

        • 1. Re: grep with variable
          Catch_22

          Where is the benefit to call a function to query individual parameters instead of the actual command if you still have to call the function for every parameter? Sorry it does not make sense to me. Perhaps you can provide a better explanation.

           

          There are default kernel parameters that do not need to listed in /etc/sysctl.conf. You can use the sysctl command line utility to query and maintain kernel parameters.

           

          For instance:

           

          sysctl kernel

          sysctl kernel.shmmax

          sysctl vm

          sysctl -a | grep max

          etc.

           

          To query several entries in /etc/sysctl with one command you could use egrep and and query separate items using the pipe character, for instance:

           

          egrep -i 'shmmax|shmall' /etc/sysctl.conf


          You probably want to use -i to ignore case distinctions.