Let's say I have the following HTML files:
html1.html
<html>
<head>
<link href="blah.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div>this here be a div, y'all</div>
</body>
</html>
html2.html
<html>
<head>
<script src="blah.js"></script>
</head>
<body>
<span>this here be a span, y'all</span>
</body>
</html>
I want to take these two files and make a master file that would look like this:
<html>
<head>
<link href="blah.css" rel="stylesheet" type="text/css" />
<script src="blah.js"></script>
</head>
<body>
<div>this here be a div, y'all</div>
<span>this here be a span, y'all</span>
</body>
</html>
Is this possible using a simple Linux command? I've tried looking at join, but it looks like that joins on a common field, and I'm not necessarily going to have common fields... I just need to basically add the difference, but also have the main structure still intact (I guess this could be referred to as a left-join?). Doesn't look like cat
will work either... as that merges by appending one file, then the next, etc.
If there isn't a simple Linux command, my next step is to either write a script that compares both scripts line by line, or create a master HTML file that references these two individual files somehow.
Use pandoc to merge e.g. all html-files in the current directory:
pandoc -s *.html -o output.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With