GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   (*)nix gurus - I need help with something... (https://gfy.com/showthread.php?t=651720)

V_RocKs 09-04-2006 12:35 AM

(*)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 09-04-2006 12:48 AM

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

darksoul 09-04-2006 12:49 AM

*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 :)

shake 09-04-2006 12:56 AM

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.

V_RocKs 09-04-2006 01:24 AM

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


All times are GMT -7. The time now is 12:40 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123