Rewrite text in a php file possible?

Discussion in 'Site & Server Administration' started by Inka, May 26, 2005.

  1. #1
    I want to rewrite text in all of php files, they all contain a line of text on the 4th line that I want to remove but since there so many I don't want to manually go through each and every one.

    So in short, I want to rewrite line 4 of all my .php ending files and replace line 4 with a simple " " space or something.

    Thanks in advance!
     
    Inka, May 26, 2005 IP
  2. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #2
    1. Download Textpad (try before you buy) (or some other decent text editor).
    2. Open all your files.
    3. Do a global search and replace. (If you need help with a Regular expression to do this, post here.)
    4. Save all files.
     
    exam, May 26, 2005 IP
  3. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #3
    UltraEdit and EditPlus have search and replace in files that can get it done.
     
    noppid, May 26, 2005 IP
  4. Inka

    Inka Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well the thing is, I need to use rewrite to do this, there's a copyright on the top of this script I have and it's impossible to remove (it's encripted in base64) but when it's in html, it always ends up on line 4, how can I rewrite line 4? thanks!
     
    Inka, May 27, 2005 IP
  5. davedx

    davedx Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You could write a PHP script that does it all for you. How many files are there?
     
    davedx, May 27, 2005 IP
  6. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I would use sed for this. This command will remove the 4th line and output the file:

    sed 4d filename.txt

    You can redirect the output or use the -i switch to edit it in place (make a backup copy first). Use the for command to process all your files.

    J.D.
     
    J.D., May 27, 2005 IP
  7. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #7
    Sounds to me like you want to do this after the PHP has already processed - since the existing script is generating the text, you want to remove it afterwards. This is a little more difficult of a prospect.

    I wouldn't know how to get that done, but it sounds like maybe it shouldn't be done anyways.
     
    nevetS, May 27, 2005 IP