Replace with sed command

Replace with sed command

am 04.01.2008 14:16:34 von sorg.daniel

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

Re: Replace with sed command

am 04.01.2008 14:21:26 von Joachim Schmitz

sorg.daniel@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

Re: Replace with sed command

am 04.01.2008 14:22:19 von Cyrus Kriticos

sorg.daniel@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.

Re: Replace with sed command

am 04.01.2008 14:36:43 von sorg.daniel

On 4 Jan., 14:21, "Joachim Schmitz"
wrote:
> sorg.dan...@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

Re: Replace with sed command

am 04.01.2008 14:57:29 von Stephane CHAZELAS

On Fri, 4 Jan 2008 05:16:34 -0800 (PST), sorg.daniel@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

Re: Replace with sed command

am 04.01.2008 16:06:18 von mik3l3374

On Jan 4, 9:16 pm, sorg.dan...@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

Re: Replace with sed command

am 04.01.2008 17:00:17 von sintral

On Jan 4, 8:57 am, Stephane Chazelas
wrote:
> On Fri, 4 Jan 2008 05:16:34 -0800 (PST), sorg.dan...@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'