Discussion: sed with /
Afficher un message
Vieux 25/03/2008, 11h05   #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
 
Page generated in 0,05114 seconds with 9 queries