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..

1

1 Answer 1

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).

1
  • 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.) Commented Dec 2, 2016 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .