I want to grep some content from an html by using regex and write that content into a new html. The example HTML is as below:
<html>
<script src='.....'>
</script>
<style>
...
</style>
<div class='header-outer'>
<div class='header-title'>
<div class='post-content'>
<noscript>
<p>content we want</p>
</noscript>
</div>
</div></div>
<div class='footer'>
</div>
</html>
Can I use grep to select content between <div class='post-content'>
and</div>
and write the content into a new html? So the new html would look like this:
<div class='post-content'>
<noscript>
<p>content we want</p>
</noscript>
</div>
I did some research on Stack overflow and found some code that might be helpful to my issue, like
grep -L -Z -r "<div class='post-content'>.*?<\/noscript><\/dive>" .| xargs -0 -I{} mv {} DIR
?
Is it correct? If it is, what does xargs
part mean? Thank you and I'm looking forward to your reply!