Parsing the html and replace the code where to dig?

Hello! Such situation: I use in their projects gulp (standard tools: jade, scssm, concat, browser-sync, minify', etc.).
The problem: need a plugin or something, who runs would be all the folders in a particular directory, and only processed html files, and they sought out certain specified pieces of code and changed them at some other specified piece of code and overwrite the html files with a different piece of code (or lay them out separately). I suspect that this plugin should be under gulp, but I can't seem to deal with the abundance of plugins, and often a modest description thereof.
And the second question: I understand that it is possible to implement such a stupid parsing through the nodejs console? Indicating the pieces of code to replace in the console. Or am I wrong and this is wrong? But it is necessary to write your own module for Node, as I understand it.

To summarize: we need to go through all these folders, to find each .html find specified pieces of code (for example:
<script src="old.js></script> <a href=http://oldlink.com"></a></code></pre>) and replace them with other code ( <pre><code><script src="NEW.js></script> <a href="http://NEWlink.com""></a>
respectively).

In General, need advice, and I'm quite confused.
PS I Use Sublime/Atom/Brackets, maybe there are some plugins for them?
Thank you for your attention.
-----------------------------
P. S. S. I Forgot to tell you that I'm just learning to write your "configs" to gulp, about how and what should be, I understand, but in no way a specialist in this matter are not.
July 2nd 19 at 14:18
3 answers
July 2nd 19 at 14:20
Solution
Would be better if you wrote that you have for the os. Without gulp you have sed solved the problem.
In Google for the query "gulp sed" comes out first https://github.com/lazd/gulp-replace
Thanks for the reply! Yes, this plugin I think will work, will definitely try it. OS - win10, unix systems familiar very superficially, so that didn't even know about the existence of sed. - Gino.Mann21 commented on July 2nd 19 at 14:23
July 2nd 19 at 14:22
If I understand correctly, you need gulp-inject
Thanks, reviewed documentation. As I understand, gulp-inject inserts the specified code, practicing their tags, for example . I really don't quite understand, is it possible to get this plugin to work not by tag and piece of code. Let's say I have in html code is: . I need the plugin found the line, removed it and put in the place of another (e.g. script src="NEW.js"> - Gino.Mann21 commented on July 2nd 19 at 14:25
July 2nd 19 at 14:24
For such a simple task can write a bash script.

Example:
for file in templates/**/*.html
do
 sed -i "s/old/NEW/g" "${file}"
done
Thanks for the reply. With bash scripts familiar in theory, but I'll try to dig in this direction a little deeper. - Gino.Mann21 commented on July 2nd 19 at 14:27

Find more questions by tags Node.jsGulp.js