I am trying to insert a piece of JavaScript before the closing <\body>
tag of over 2000 HTML files. This is what I have tried. But it does not do the job.
perl -pi -w -e 's/\<\/body\>/\<div id=\"fb-root\"\>\<\/div\>
\<script type=\"text\/javascript\" src=\"https:\/\/connect.facebook.net\/en_US\/all.js\"\>\<\/script\>
\<script type=\"text\/javascript\"\>
FB.init\(\{
appId: \"446059218762070\",
status: true,
cookie: true,
xfbml: true
});
\/\* As of Jan 2012 you need to use \*\/
FB.Canvas.setAutoGrow\(2\);
\<\/script\>
\<\/body\>/g' *.html
I have done some other replacement scripts with perl -pi
, that worked well like
perl -pi -w -e 's/\<a href=\"index.html\"\>/\<a class=\"top_button\" href=\"index.html\"\>/g' *.html
and
perl -pi -w -e 's/\<link rel=\"STYLESHEET\" type=\"text\/css\" href=\"default.css\"\>/\<link rel=\"STYLESHEET\" type=\"text\/css\" href=\"default.css\"\>
\<script type=\"text\/javascript\" src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.4\/jquery.min.js\"\>\<\/script\>
\<script type=\"text\/javascript\" src=\"default.js\"\>\<\/script\>/g' *.html
Can anyone help me? what is wrong with my one-liner Perl script?