Delete a line from the fil

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajd335
    New Member
    • Apr 2008
    • 123

    Delete a line from the fil

    hi all

    i have a directory in which there are numbers of files.
    Each file contains the following code at the end

    Code:
     
    <p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close()" /></p>
    i want to remove that code from all the files in the directory

    I have tried out

    Code:
     perl -pi -e 's/<p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close()" \/><\/p> /           /gi'  .*php
    but it's not working..is there any other way to do so..
    I have tried out sed command also
    sed 'N;$;$;$d' filename but still not working..
    Last edited by eWish; Apr 28 '08, 11:34 PM. Reason: Fixed code tags
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Originally posted by ajd335
    hi all

    i have a directory in which there are numbers of files.
    Each file contains the following code at the end

    [code ]
    <p align="right">< input name="closeme" type="button" value="Close Window" onclick="self.c lose()" /></p>
    [/code]

    i want to remove that code from all the files in the directory

    I have tried out

    Code:
     perl -pi -e 's/<p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close()" \/><\/p> /           /gi'  .*php
    but it's not working..is there any other way to do so..
    I have tried out sed command also
    sed 'N;$;$;$d' filename but still not working..

    Try:

    Code:
     perl -pi -e 's/<p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close\(\)" \/><\/p> /           /gi'  .*php
    The parenthesis should be escaped \(\) otherwise perl will see them as capturing brackets and not literal parenthesis. I'm not sure if perl expands .*php into a list of files to edit. Hopefully it does.

    Comment

    • ajd335
      New Member
      • Apr 2008
      • 123

      #3
      Originally posted by KevinADC
      Try:

      Code:
       perl -pi -e 's/<p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close\(\)" \/><\/p> /           /gi'  .*php
      The parenthesis should be escaped \(\) otherwise perl will see them as capturing brackets and not literal parenthesis. I'm not sure if perl expands .*php into a list of files to edit. Hopefully it does.

      Thanks Kevin..
      IT's working

      Comment

      Working...