Enter data in the middle of a file after doing some pattern matching

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • powerfulperl
    New Member
    • Feb 2010
    • 14

    Enter data in the middle of a file after doing some pattern matching

    I Have a file by the name relog.001

    I want to search for a line Local=IN
    If found then skip

    If not found then search for a line starting with 'Testion option Ok'
    then insert the line 'Local=IN' after that.

    File relog.001 contents before inserting
    gpg RC (54321)
    Testion Option OK
    AIX.SHA1.So


    File relog.001 contents after inserting
    gpg RC (54321)
    Testion Option OK
    Local=IN
    AIX.SHA1.So


    Note :- I am passing the Rvalue 'IN' from subroutine, and it can change like (IN or US or FR) so I need to evaluate it with a regular expression.

    lvalue 'Local=Regulare xpression'.

    Hope it makes sense, quick reply will be appreciated.
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    You will notice that I deleted your duplicate thread. Please, DO NOT post the same question twice. If you want to post in this same thread and ask if anyone has input, feel free, but please know that the weekends are slow going and an answer may not come till Monday.

    Comment

    • RonB
      Recognized Expert Contributor
      • Jun 2009
      • 589

      #3
      What part of the process do you not know how to do or is giving you trouble?

      Which part of the solutions that you've already been given do you not understand and/or are not working as expected?

      Do you understand the solutions that you've been given?

      Are you looking for help in troubleshooting , or do you simply want someone to provide you with a complete script that has been tested against your input data?

      Comment

      Working...