Results 1 to 3 of 3
I have a file that is in almost all my /home web accounts, here:
/home/accountXXXX/public_html/cms3.0.php
in that file is a line I want to get rid of:
<script id="jslocal" language="JavaScript" ...
- 06-27-2011 #1Just Joined!
- Join Date
- Apr 2003
- Posts
- 52
how to yank (and even cooler replace) a line in a bunch of files
I have a file that is in almost all my /home web accounts, here:
/home/accountXXXX/public_html/cms3.0.php
in that file is a line I want to get rid of:
<script id="jslocal" language="JavaScript" type="text/javascript" src="/site-local/local.js"></script>
is there a simple shell script that would recurse all /home/xxx/public_html directories, and then yank this line (it will always be exactly the same)
and better yet, for future, is there any way I can REPACE that line with another.. for now I'd be happy to get rid of it
Thank you, if you need PHP help, go over to php builder dot com - *that* I can help you with
I am sfullman over there
- 06-27-2011 #2Notes:Code:
find /home/account*/public_html/ -type f -name "cms3.0.php" | while read FILENAME; do sed '/<script id="jslocal" language="JavaScript" type="text\/javascript" src="\/site-local\/local.js"><\/script>/c // PLACEHOLDER' ${FILENAME};done
- Be sure to escape the /
- If the result is to your liking, (watch out for multiple matches per file), then call sed with sed -iYou must always face the curtain with a bow.
- 06-28-2011 #3Just Joined!
- Join Date
- Sep 2007
- Posts
- 51
Perl response
find /home/account????/public_html/ -name cms3.0.php -exec perl -pi -e 's/<script id="jslocal" language="JavaScript" type="text\/javascript" src="\/site-local\/local.js"><\/script>/this works pretty nice/' {} \;
This works in much the same way as the example given above except a perl script is used.
So much we can learn from one another, I love this site.
T


Reply With Quote