How to replace single quote (') with backslash and then single quote (\) with sed?
sed s/\'/\\\'/
will not work because you can never write a literal.
sed ":a;N;s/\'/\\'/g" <file1 >file2
will not work because the backslash will no longer remove the quote; it is treated as a quote from the regular expression.
just specify a replacement
$ echo \' | sed s/\'/"\\\'"/ $ \'
eg
$ cat text1 this is a string, it has quotes, that its quality $ sed s/\'/"\\\'"/ text1 > text2 $ cat text2 this is a string, it has quotes, that\ its quality
Try the following:
sed -es/\'/\\\\\'/g input > output
To prove that this works:
echo "Hello 'World'" | sed -es/\'/\\\\\'/g
The output should be:
Hello \'World\'
how about: sed "s, ', BBBB', g" file where B is the backslash ... these are 4 backslashes ...
Use the -e option.
sed -es / \ '/ \\' / g file2
It works:
<<<"''''" sed 's/'\''/\\&/;s/\('"'"'\)\(..\)$/\\\1\2/;'s/\'\'$/\\\\\'\'/";s/'$/\\\'/" \'\'\'\'
Source: https://habr.com/ru/post/901149/More articles:Linux file permissions for USB device on Android - androidhow to find overridable methods in eclipse - javaMake OpenCover Reports Available in CruiseControl.NET - Code-coverageRecalculate claims for a SharePoint 2010 user while the user is still registered - claims-based-identityIs there a way to tell IntelliJ IDEA which output folder to use for the GWT compiler? - compiler-constructionHow to implement a self-promotion model (parent_id) in cakephp - database-designDynamically adding spring context configuration at runtime? - javaAndroid "ant install" fails with the error "Install file not specified." - androidMy Python-Java interface, good design? And how to wrap JNI functions? - javaEclipse Android will not clear, do not update resources - androidAll Articles