How to copy contents of a text file into another file at a specific location
Hi everyone,
I have thousands of html files and I need to put a google plus button in each file. I don't feel like editing thousands of files manually so I want to do it with a linux command but can't figure out how to do it.
I have the following text in a file called googleplus.txt
<!-- Google Plus Button START -->
<div class="g-plusone" data-annotation="inline" data-width="300"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<!-- Google Plus Button END -->
I want to be able to place this block of text (above), which is in the file googleplus.txt into each of the thousand files just after a line called:
<!-- AddThis Button END -->
So once the job is done, each file should end up like this:
<!-- AddThis Button END -->
<!-- Google Plus Button START -->
<div class="g-plusone" data-annotation="inline" data-width="300"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<!-- Google Plus Button END -->
How can I do this to all html files in a diectory?
Any help would be greatly appreciated.
Thanks
Andy
|