(*)nix gurus - I need help with something...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • V_RocKs
    Damn Right I Kiss Ass!
    • Nov 2003
    • 32449

    #1

    (*)nix gurus - I need help with something...

    What can I do on the command line to achieve this:

    Code:
    <? include("file"); ?>
    I wan't to insert that into each file called index.php in recursive directories.

    So say I have:

    domain.com/teens
    domain.com/latinas
    domain.com/lesbians

    And each directory (teens, latinas and lesbians) has a file called index.php in it and I want that include code to be added to the TOP of (prepended to) the file.

    Anyone know of some command line code or a bash script that can achive this?
  • PussyTeenies
    Confirmed User
    • Feb 2005
    • 6496

    #2
    Code:
    for i in $(find ./ -name index.php); do cat $i |sed -e "s#<html>#<html><? include \(\"file\"\); ?>#" > $-new && mv $i-new $i;done
    using the html as first line in the file

    i know it can be done with first line crap :P awk,sed,vi you name it :D

    too tired to think
    Need adult hosting?

    Contact us!
    WARM Hosting

    Need an IT solution? or someone to check your site and security? Nossie - IT Professional

    Comment

    • darksoul
      Confirmed User
      • Apr 2002
      • 4997

      #3
      *not tested*
      put your code in a file code.txt then:

      script.sh
      Code:
      #!/bin/sh
      for i in `find . -name index.php`;
      do
            cat /path/to/code.txt $i > /tmp/newfile.tmp
            mv /tmp/newfile.tmp $i
      done
      run the script in the main directory.

      BACKUP first
      1337 5y54|)m1n: 157717888
      BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
      Cambooth

      Comment

      • shake
        frc
        • Jul 2003
        • 4663

        #4
        Don't forget: you can always run php on the command line too Unless you have it installed as a DSO module in apache, but in that case you can install the stand-alone executable as well - what ever version you need.
        Crazy fast VPS for $10 a month. Try with $20 free credit

        Comment

        • V_RocKs
          Damn Right I Kiss Ass!
          • Nov 2003
          • 32449

          #5
          Darksouls appears to be correct.. will make a fake spot on the server and try it.

          Comment

          Working...