You can't escape a single quote within a string quoted with single quotes. So you have to close the quote, add an escaped quote, then open the quotes again. That is:
'foo'\''bar', which breaks down as:
- (optional) You don't necessarily have to use
/ in sed. I find that using
\ in the same sed expression makes it difficult to read.
For example, to remove the quotes from this file:
$ cat /tmp/f
Given my two tips above, the command you can use to remove both double and single quotes is:
$ sed -e 's|["'\'']||g' /tmp/f
Based on my first tip, the shell reduces sed's second argument
(i.e., the string after the
s|["']||g and passes that string to sed.
Based on my second tip, sed treats this the same as
remove all characters matching either
" (i.e., replace them with nothing)
You probably need something more complex than this to do what you want, but it's a start.