-1

I have arounf 50 html files and I have to replace the integrity and sha part with the empty lines

in all the html files we can find common JS with

<script crossorigin='anonymous' integrity='sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q' src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js'></script>

I need to replace this with just the

<script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js'></script>

I tried sed command with

sed -i -e 's|<script crossorigin='anonymous' integrity='sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q' src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js'></script>|<script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js'></script>|g' *.html 

It did not replace any of that

oguz ismail
  • 1
  • 16
  • 47
  • 69
DirectedSoul
  • 81
  • 10

2 Answers2

0

as simple as below with the given string and considering everything to be removed between first and last spaces, and no spaces in the URL string, so here you go:

< test.txt sed 's/ .* / /'
<script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js'></script>

while test.txt contains the original string.

Ibraheem
  • 149
  • 12
-1

I finally managed to figure this out and managed to replace the js in all my html files

sed -i -e "s|<script crossorigin='anonymous' integrity='sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q' src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js'></script>|<script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js'></script>|" *.html ```
DirectedSoul
  • 81
  • 10