Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Perl program to edit a file

Expand Messages
  • merlyn@stonehenge.com
    ... tr Hi, tr I am writing a script to automate the kernel parameter setting. tr Say for eg. in linux edit sysctl.conf has kernel.shmmax=2147483648 tr
    Message 1 of 2 , Oct 7, 2006
    • 0 Attachment
      >>>>> "tr" == tr rajeshkanna <tr_rajeshkanna@...> writes:

      tr> Hi,
      tr> I am writing a script to automate the kernel parameter setting.

      tr> Say for eg. in linux edit sysctl.conf has kernel.shmmax=2147483648

      tr> which i need to disable and display as #kernel.shmmax

      @ARGV = "/home/rajesh/sysctl.conf";
      $^I = ".bak"; # inplace edit
      while (<>) {
      s/^(kernel.shmmax)/#$1/; # comment this out if you see it
      print; # print everything into new file
      }

      That edits your file in place, creating a backup file.

      --
      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
      Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
      See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Your message has been successfully submitted and would be delivered to recipients shortly.