Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[bash] question sur sed
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index French
View previous topic :: View next topic  
Author Message
luteola
Tux's lil' helper
Tux's lil' helper


Joined: 03 Mar 2006
Posts: 118
Location: Bruxelles

PostPosted: Mon Oct 02, 2006 8:37 pm    Post subject: [bash] question sur sed Reply with quote

salut

Dans plusieurs fichiers, je cherche à remplacer une chaîne de caractères

Code:
pg&fr


par

Code:
pg.fr


Hélas, un

Code:
sed 's/pg&fr/pg.fr/g' fichier > fichier.new

ne fonctionne pas :-( Le caractère & est mal interprété. J'ai bien essayé de le protéger par un \ mais rien n'y fait. J'ai tout essayé : mettre en variable, faire un `echo variable` à la place etc rien n'y fait :-(

une idée ??

merci !

a+
_________________
www.guidelinux.org
________________________________________
Gentoo amd64 2007.0
Asus A8N32-SLI
AMD Athlon 4000+, 2Go DDR400
NVIDIA 7900GTX
Soundblaster Audigy 4
Back to top
View user's profile Send private message
Ascodas
Apprentice
Apprentice


Joined: 18 Nov 2004
Posts: 263

PostPosted: Mon Oct 02, 2006 9:12 pm    Post subject: Reply with quote

Pourtant chez moi :

Quote:
[thomas@amd64 scripts]$ cat essai.txt
pg&fr
[thomas@amd64 scripts]$ sed 's/pg\&fr/pg.fr/g' essai.txt > essai.txt.ok
[thomas@amd64 scripts]$ cat essai.txt.ok
pg.fr
[thomas@amd64 scripts]$


Ton idée de protéger le & est bonne.
Back to top
View user's profile Send private message
truc
Advocate
Advocate


Joined: 25 Jul 2005
Posts: 3199

PostPosted: Mon Oct 02, 2006 9:13 pm    Post subject: Reply with quote

euh
Code:
$ cat test
pg&fr
$ cat test | sed 's/pg&fr/pg.fr/'
pg.fr


ça marche ici,j'comprends pas trop ton problème?

EDIT: grilled, note que je n'ai même pas besoin d'échapper le &
_________________
The End of the Internet!
Back to top
View user's profile Send private message
luteola
Tux's lil' helper
Tux's lil' helper


Joined: 03 Mar 2006
Posts: 118
Location: Bruxelles

PostPosted: Mon Oct 02, 2006 9:29 pm    Post subject: Reply with quote

salut

je viens de me rendre qu'effectivement ca marche. Le truc c'est que je lancais la commande sur tout plein de fichiers. Et que bizarrement, une chaine à remplacer est restée. C'est pour ca que je pensais que ca fonctionnait pas. En fait ca fonctionne à 99%. Je continue mes petites recherches pour comprendre. Merci pour votre aide.

a+
_________________
www.guidelinux.org
________________________________________
Gentoo amd64 2007.0
Asus A8N32-SLI
AMD Athlon 4000+, 2Go DDR400
NVIDIA 7900GTX
Soundblaster Audigy 4
Back to top
View user's profile Send private message
truc
Advocate
Advocate


Joined: 25 Jul 2005
Posts: 3199

PostPosted: Mon Oct 02, 2006 10:19 pm    Post subject: Reply with quote

si la chaine à remplacer apparait plusieurs fois sur une même ligne alors ne pas oublier l'option 'g' 's/pg&fr/pg.fr/g'
_________________
The End of the Internet!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum