| Author |
Replacing single quote with double quote in a line
|
|
| equation 2007-02-22, 7:08 pm |
| Hello group,
I am looking for a single sed line for replacing single quote with
double quote in a line.
I prefer a one step process rather than two seds in pipe.
Thanks
| |
| Giorgos Keramidas 2007-02-22, 7:08 pm |
| On 22 Feb 2007 10:49:50 -0800, "equation" <equation@techemail.com> wrote:
> Hello group,
> I am looking for a single sed line for replacing single quote with
> double quote in a line.
>
> I prefer a one step process rather than two seds in pipe.
You don't need two sed pipes:
$ echo "'hello world'" | sed -e 's/'''/"/g'
"hello world"
$
| |
| Ed Morton 2007-02-22, 10:06 pm |
| equation wrote:
> Hello group,
>
> I am looking for a single sed line for replacing single quote with
> double quote in a line.
>
> I prefer a one step process rather than two seds in pipe.
>
> Thanks
>
sed "s/'/\"/g"
| |
| Rainer Weikusat 2007-02-23, 4:14 am |
| "equation" <equation@techemail.com> writes:
> I am looking for a single sed line for replacing single quote with
> double quote in a line.
tr "'" "\""
| |
| Logan Shaw 2007-02-23, 10:08 pm |
| Rainer Weikusat wrote:
> "equation" <equation@techemail.com> writes:
>
> tr "'" "\""
Nice solution. I think it's prettier if you write it this way:
tr "'" '"'
Or this way:
tr ' \"
I guess part of my point is that symmetry is nice.
- Logan
| |
| Logan Shaw 2007-02-23, 10:08 pm |
| equation wrote:
> Hello group,
>
> I am looking for a single sed line for replacing single quote with
> double quote in a line.
>
> I prefer a one step process rather than two seds in pipe.
I prefer using a character other than "/" in sed expressions where you
are going to use backslashes. It's tricky for the eye to make sense of
a string that has a bunch of slashes and backslashes in it. So:
sed -e s:':\":g
Or, you can take advantage of the fact that you can quote either type of
quote character with the other type and the fact that you can begin and
stop quoting in the middle of a string:
sed -e s:"'":'"':g
- Logan
| |
| Michael Paoli 2007-02-25, 4:07 am |
| On Feb 22, 6:21 pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
> equation wrote:
> sed "s/'/\"/g"
Or with one fewer quoting characters:
sed -e s/'/\"/g
|
|
|
|