Hello Zapzapzoo,
I am glad that you found a solution based on the request for question
clarification. Not using quotes but using \ for all special characters
does work. It is also easier to explain than the quoting rules in
bash.
Using your example:
sed 's/\"/\'/g' filename > output
and reviewing the quoting rules from the bash man page at
http://www.die.net/doc/linux/man/man1/bash.1.html
it states in part:
Enclosing characters in single quotes preserves the literal
value of each character within the quotes. A single quote
may not occur between single quotes, even when preceded by
a backslash.
The combination of \' actually terminates the string above. The
remainder of the line is a second string (not terminated).
The interpretation of that command is basically...
sed is the first (or 0th) parameter
's/\"\' is the contents of the first quoted string
/g is between the first and second quoated string
' filename > output (and any more text until another ') is the
second quoted string
The prompt you see (>) is actually bash requesting more input. Enter a
' to that prompt to finish the command to see what I mean (but it
still won't work quite right...)
You could rewrite that command line as:
sed "s/\"/'/g" filename > output
to get the behavior I believe you expect.
This is because a double quote string preserves the literal value of
all characters except \, $, and `. The backslash has its special
meaning only if followed by ", $, `, \, and newline.
I hope this additional explanation of the quoting rules in bash will
help you in this (and any future) task. Good luck with your work.
--Maniac
¬ |