Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I do a multi-line find & replace from *Nix command line?
    primarykey
    data
    text
    <p><strong>I have a bunch of files with some old google tracking code at the bottom of the page: </strong></p> <pre> &lt;script type=&quot;text/javascript&quot;&gt; var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;); document.write(unescape(&quot;%3Cscript src='&quot; + gaJsHost + &quot;google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E&quot;)); &lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; try { var pageTracker = _gat._getTracker(&quot;UA-XXXXXXXXX-1&quot;); pageTracker._trackPageview(); } catch(err) {}&lt;/script&gt; </pre> <p><strong>I need to update that so that it has the new version of the GA code: </strong></p> <pre> &lt;script type=&quot;text/javascript&quot;&gt; var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxxxx-1']); _gaq.push(['_setDomainName', 'site.com']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); &lt;/script&gt; </pre> <p>Normally I would use <code> find . -name "*html" -exec sed s/find/replace/ {} \; </code> to do this, but from what I understand it can't handle multi lines. How do I modify something like this to do a find and replace for multi lines, and how do I easily deal with all that stuff I'd have to escape at the command line? I'm not against creating a bash file.</p> <p>I am also not against putting the "find" and "replace" stuff in text files and then pulling it into the command that way - at least that should make the escaping part easier.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload