Replace with sed command

Hi,

I have a problem, i'd like to replace the "."(point) with the /
put i get the following error:
sed: -e Ausdruck #1, Zeichen 6: unknown option to `s'
There is the code.

========================================
#!/bin/sh

TEMP="com.mycompany.app"
echo "$TEMP"
echo $TEMP | sed -e 's/.///g'

========================================
I'd like this result: com/mycompany/app

Thanks in advance!

Daniel
sorg.daniel [ Fr, 04 Januar 2008 14:16 ] [ ID #1899390 ]

Re: Replace with sed command

sorg.daniel [at] googlemail.com wrote:

>
> I have a problem, i'd like to replace the "."(point) with the /
> put i get the following error:
> sed: -e Ausdruck #1, Zeichen 6: unknown option to `s'
> There is the code.
>
> ========================================
> #!/bin/sh
>
> TEMP="com.mycompany.app"
> echo "$TEMP"
> echo $TEMP | sed -e 's/.///g'
>
> ========================================
> I'd like this result: com/mycompany/app

escape . and / with a \

sed -e 's/\./\//g'

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
Cyrus Kriticos [ Fr, 04 Januar 2008 14:22 ] [ ID #1899391 ]

Re: Replace with sed command

sorg.daniel [at] googlemail.com wrote:
> Hi,
>
> I have a problem, i'd like to replace the "."(point) with the /
> put i get the following error:
> sed: -e Ausdruck #1, Zeichen 6: unknown option to `s'
> There is the code.
>
> ========================================
> #!/bin/sh
>
> TEMP="com.mycompany.app"
> echo "$TEMP"
> echo $TEMP | sed -e 's/.///g'
echo $TEMP | sed -e 's/\./\//g'
or
echo $TEMP | sed -e 's:\.:/:g'

>
> ========================================
> I'd like this result: com/mycompany/app
>
> Thanks in advance!
>
> Daniel
Bye, Jojo
Joachim Schmitz [ Fr, 04 Januar 2008 14:21 ] [ ID #1899392 ]

Re: Replace with sed command

On 4 Jan., 14:21, "Joachim Schmitz" <nospam.j... [at] schmitz-digital.de>
wrote:
> sorg.dan... [at] googlemail.com wrote:
> > Hi,
>
> > I have a problem, i'd like to replace the "."(point) with the /
> > put i get the following error:
> > sed: -e Ausdruck #1, Zeichen 6: unknown option to `s'
> > There is the code.
>
> > ========================================
> > #!/bin/sh
>
> > TEMP="com.mycompany.app"
> > echo "$TEMP"
> > echo $TEMP | sed -e 's/.///g'
>
> echo $TEMP | sed -e 's/\./\//g'
> or
> echo $TEMP | sed -e 's:\.:/:g'
>
>
>
> > ========================================
> > I'd like this result: com/mycompany/app
>
> > Thanks in advance!
>
> > Daniel
>
> Bye, Jojo

Thank you, that's it..
Regards, Daniel
sorg.daniel [ Fr, 04 Januar 2008 14:36 ] [ ID #1899393 ]

Re: Replace with sed command

On Fri, 4 Jan 2008 05:16:34 -0800 (PST), sorg.daniel [at] googlemail.com wrote:
> Hi,
>
> I have a problem, i'd like to replace the "."(point) with the /
> put i get the following error:
> sed: -e Ausdruck #1, Zeichen 6: unknown option to `s'
> There is the code.
>
> ========================================
> #!/bin/sh
>
> TEMP="com.mycompany.app"
> echo "$TEMP"
> echo $TEMP | sed -e 's/.///g'
>
> ========================================
[...]

printf '%s\n' "$TEMP" | tr . /

See also:

IFS=.
set -f
set -- $TEMP
IFS=/
newTEMP="$*"

(note that it works differently in Unix shells and in old Bourne
shells, and that the Unix standard sh is not necessarily in /bin
like on Solaris).

--
Stephane
Stephane CHAZELAS [ Fr, 04 Januar 2008 14:57 ] [ ID #1899394 ]

Re: Replace with sed command

On Jan 4, 9:16 pm, sorg.dan... [at] googlemail.com wrote:
> Hi,
>
> I have a problem, i'd like to replace the "."(point) with the /
> put i get the following error:
> sed: -e Ausdruck #1, Zeichen 6: unknown option to `s'
> There is the code.
>
> ========================================
> #!/bin/sh
>
> TEMP="com.mycompany.app"
> echo "$TEMP"
> echo $TEMP | sed -e 's/.///g'
>
> ========================================
> I'd like this result: com/mycompany/app
>
> Thanks in advance!
>
> Daniel

# echo $TEMP | tr "." "/"
com/mycompany/app
mik3l3374 [ Fr, 04 Januar 2008 16:06 ] [ ID #1899401 ]

Re: Replace with sed command

On Jan 4, 8:57 am, Stephane Chazelas <stephane_chaze... [at] yahoo.fr>
wrote:
> On Fri, 4 Jan 2008 05:16:34 -0800 (PST), sorg.dan... [at] googlemail.com wrote:
> > Hi,
>
> > I have a problem, i'd like to replace the "."(point) with the /
> > put i get the following error:
> > sed: -e Ausdruck #1, Zeichen 6: unknown option to `s'
> > There is the code.
>
> > ========================================
> > #!/bin/sh
>
> > TEMP="com.mycompany.app"
> > echo "$TEMP"
> > echo $TEMP | sed -e 's/.///g'
>
> > ========================================
>
> [...]
>
> printf '%s\n' "$TEMP" | tr . /
>
> See also:
>
> IFS=.
> set -f
> set -- $TEMP
> IFS=/
> newTEMP="$*"
>
> (note that it works differently in Unix shells and in old Bourne
> shells, and that the Unix standard sh is not necessarily in /bin
> like on Solaris).
>
> --
> Stephane

This works too:

TEMP="com.mycompany.app"
echo $TEMP | sed 's/\./\//g'
sintral [ Fr, 04 Januar 2008 17:00 ] [ ID #1899414 ]
Linux » comp.unix.shell » Replace with sed command

Vorheriges Thema: question on awk
Nächstes Thema: adding a word at the end of each line