Last active
October 6, 2020 14:57
-
-
Save ppenguin/e170c64269e42dc62895ab2002021bab to your computer and use it in GitHub Desktop.
bash (portable) quote a single quote in double quotes for substitution in a single quoted field (for use in e.g. borg --exclude pattern)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# or, in other words: close single quote ' | dquote squote "'" | start single quote ', but this all quoted within single quotes for the sed command | |
# so this sed MUST ONLY be used for text which is substituted in a field which is itself quoted in single quotes (as in our --exclude='<pattern>') | |
<crazy output with string including single quote(s)> | sed -e 's/'"'"'/'"'"'"'"'"'"'"'"'/g' | awk ... -v q="'" '{ printf "--exclude="q"*/%s"q" ", $1 }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment