Results 1 to 2 of 2

Thread: Adding a line to a file

  1. #1
    Associate
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    13

    Adding a line to a file

    Hi,
    I need to add the line:
    #!/usr/local/bin/php
    to the beginning of a bunch of PHP files in several directories. Is there a SED command that can do this?

    Thanks,
    Roy

  2. #2
    Associate
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    13

    Re: Adding a line to a file

    My hosting provider (www.aldenhosting.com) sent me this:

    fix_php() {
    chmod -v 551 $file # Make them executable

    if [ `grep -c '/usr/local/bin/php' $file ` -eq 0 ]
    then
    echo "No /usr/local/bin/php found in file $file I am adding
    it to the top of file";
    echo '#!/usr/local/bin/php' > web.tmp
    cat $file >> web.tmp
    cp --force web.tmp $file
    fi
    }
    # This calls the above fix_php for each file in html diretcory
    for file in ` find /webs/web_q9/q9asdfgh/html -name '*.php' `
    do
    fix_php
    done :wink:

Similar Threads

  1. How to use the Sysprep tool
    By CoolJsa14 in forum Windows - General Topics
    Replies: 0
    Last Post: 01-05-2005, 09:34 PM
  2. Drawing Tools: Pencil, Line, Arc, Freeform,
    By The Donald in forum Windows - General Topics
    Replies: 0
    Last Post: 01-05-2005, 07:27 AM
  3. File Formats Supported by Windows Media Player
    By regix in forum Windows - General Topics
    Replies: 0
    Last Post: 01-03-2005, 11:17 PM
  4. Calling all mail server admins
    By demian in forum Linux - Hardware, Networking & Security
    Replies: 4
    Last Post: 04-21-2004, 08:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •