0

This is my foo.sh:

#!/bin/bash

sed -i -- 's/<meta http-equiv="Content-Security-Policy" content="default-src * data: blob: 'unsafe-inline' 'unsafe-eval' ws: wss:;">/<meta my custom meta>/g' ../app-prod/ios/project/www/application/index.html

I can't understand how to escape single & double quotes and asterisk symbols..

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Edgar
  • 1

1 Answers1

2

You'll probably want to use double quotes around your sed. Then escape double quotes and wildcards inside your expression. Something like this should do:

sed -i "s|<meta http-equiv=\"Content-Security-Policy\" content=\"default-src \* data: blob: 'unsafe-inline' 'unsafe-eval' ws: wss:;\">|<meta my custom meta>|g" /path/to/file.html

(not certain about double quoting the whole expression. I seem to remember that escaping single quotes in single-quoted expressions can fail under some conditions, ... which I couldn't name).

SYN
  • 2,863
  • 3
    POSIX (and friends) sh's single quotes are raw quotes without escapes, so you are expected to use something 'blah'\''blah' when you need a single quote (end the current single-quoted part, add an escaped single quote, and start a new single-quoted part.) – Mingye Wang Dec 02 '16 at 17:53