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 > sed with /
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

sed with /

Réponse
 
LinkBack Outils de la discussion
Vieux 25/03/2008, 00h45   #1
zw
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut sed with /

Hi Gurus

I'm new to sed.
How does one replace / with // for a string for example
//filer/test/test2/test3/test4 to become ////filer//test/t/test2//
test3//test4 ?
I have tried a variety like
TEMP_VAR=`/usr/bin/sed -e 's/\//K/g' //filer/test/test2/test3/test4 `
and I still can't get it right.
I'm not sure how to escape /.

Any is appreciated.
  Réponse avec citation
Vieux 25/03/2008, 00h59   #2
Janis Papanagnou
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sed with /

zw wrote:
> Hi Gurus
>
> I'm new to sed.
> How does one replace / with // for a string for example
> //filer/test/test2/test3/test4 to become ////filer//test/t/test2//
> test3//test4 ?


Use another delimiter than the usual / in your sed call, e.g. a comma...

sed 's,/,//,g'


Janis

> I have tried a variety like
> TEMP_VAR=`/usr/bin/sed -e 's/\//K/g' //filer/test/test2/test3/test4 `
> and I still can't get it right.
> I'm not sure how to escape /.
>
> Any is appreciated.

  Réponse avec citation
Vieux 25/03/2008, 01h07   #3
zw
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sed with /

On Mar 24, 4:59pm, Janis Papanagnou <Janis_Papanag...@hotmail.com>
wrote:
> zw wrote:
> > Hi Gurus

>
> > I'm new to sed.
> > How does one replace / with // for a string for example
> > //filer/test/test2/test3/test4 to become ////filer//test/t/test2//
> > test3//test4 ?

>
> Use another delimiter than the usual / in your sed call, e.g. a comma...
>
> sed 's,/,//,g'
>
> Janis
>
>
>
> > I have tried a variety like
> > TEMP_VAR=`/usr/bin/sed -e 's/\//K/g' //filer/test/test2/test3/test4 `
> > and I still can't get it right.
> > I'm not sure how to escape /.

>
> > Any is appreciated.- Hide quoted text -

>
> - Show quoted text -


Janis thanks for responding. I'ms till not getting what I want.
I think it has to do with Ant task <shellscript>
  Réponse avec citation
Vieux 25/03/2008, 01h30   #4
Maxwell Lol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sed with /

zw <MPC8250@gmail.com> writes:

> Janis thanks for responding. I'ms till not getting what I want.
> I think it has to do with Ant task <shellscript>


Show input and desired output.... Thanks.
  Réponse avec citation
Vieux 25/03/2008, 05h48   #5
Cyrus Kriticos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sed with /

zw wrote:
>
> I'm new to sed.
> [...]
> I'm not sure how to escape /.


with a \

--
Best regards | Monica Lewinsky's X-Boyfriend's
Cyrus | Wife for President
  Réponse avec citation
Vieux 25/03/2008, 10h05   #6
pk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sed with /

zw wrote:

> Hi Gurus
>
> I'm new to sed.
> How does one replace / with // for a string for example
> //filer/test/test2/test3/test4 to become ////filer//test/t/test2//
> test3//test4 ?


$ echo '//filer/test/test2/test3/test4' | sed 's%/%//%g'
////filer//test//test2//test3//test4

or, much less readable

$ echo '//filer/test/test2/test3/test4' | sed 's/\//\/\//g'
////filer//test//test2//test3//test4

You can use almost any character in place of the / to separate the
expressions.

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
  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 06h57.


É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,10213 seconds with 14 queries