PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Replace with sed command
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Replace with sed command

Réponse
 
LinkBack Outils de la discussion
Vieux 04/01/2008, 13h16   #1
sorg.daniel@googlemail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
  Réponse avec citation
Vieux 04/01/2008, 13h21   #2
Joachim Schmitz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Replace with sed command

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


  Réponse avec citation
Vieux 04/01/2008, 13h22   #3
Cyrus Kriticos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Replace with sed command

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.
  Réponse avec citation
Vieux 04/01/2008, 13h36   #4
sorg.daniel@googlemail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Replace with sed command

On 4 Jan., 14:21, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
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
  Réponse avec citation
Vieux 04/01/2008, 13h57   #5
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Replace with sed command

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
  Réponse avec citation
Vieux 04/01/2008, 15h06   #6
mik3l3374@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Replace with sed command

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
  Réponse avec citation
Vieux 04/01/2008, 16h00   #7
sintral
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Replace with sed command

On Jan 4, 8:57 am, Stephane Chazelas <stephane_chaze...@yahoo.fr>
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'
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 08h18.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15992 seconds with 15 queries