in reply to Changing parameters

Do you mean you want to edit parameter.ph from the command line?

perl -pi.bak -e 's!\$i = 2;!\$i = 4;!' parameter.ph

Replies are listed 'Best First'.
Re^2: Changing parameters
by sparkel (Acolyte) on Nov 29, 2004 at 16:46 UTC
    Hi,

    Thanks for the reply.

    Is there another way of changing both the values of i and j without knowing what their current values are?

    Your suggestion above does work, but it requires knowing what the current values are of i inorder to change it from 2 to 4.

    Thank you.

      How about:

      perl -pi.bak -e 's!\$i = .*?;!\$i = 4;!' parameter.ph
        Thank you fglock
      You could just append new values to the file.
      echo '$i = 987;' >> parameter.ph
      That will override the old values.

      If you do this often, and do not want the file to grow every time, save the original file and output to a new one.

      cp defaults.ph parameter.ph; echo '$i = 987;' >> parameter.ph