[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [linux-team] replace massif
On Thu, Aug 26, 1999 at 11:24:39AM +0200, Frederic Dumont wrote:
> On Wed, Aug 25, 1999 at 06:49:03PM +0200, Frederic Dumont wrote:
> > On Wed, Aug 25, 1999 at 06:36:49PM +0200, aef@salsa.be.eu.org wrote:
> > > Quelle est la commande qui permet de remplacer la
> > > chaine "brol" par "truc" dans tous les fichiers *.html
> > > du repertoire /home/coucou ?
> >
> > Une facon de faire, avec bash et sed:
> > cd /home/coucou ; for i in *.html; do mv -i $i `echo $i | sed -e
> > 's/brol/truc/'`; done
>
> Oups, grosse erreur: cette commande remplace brol par truc dans les _noms_ de
> fichiers. Bon, je crois que d'autres ont finalement repondu a la question
> initiale, donc je ne vais meme pas essayer de me corriger.
Effectivement. Pour remplacer le contenu avec sed:
for i in /home/coucou/*.html
do
mv "$i" "$i.bak"
cat "$i.bak" | sed -e 's/brol/truc/g' > "$i"
done
Mais je trouve tjs la version Perl plus jolie (et plus courte) ;))
--
-o) / Pascal Bleser ATOS Payment Systems|
/\\ \ C++/UNIX Development Aachen, Germany|
_\_v \<guru@linuxbe.org> <pbleser@atos-group.com>|
---------------------------------------------------|
The brain is a wonderful organ; it starts working :
the moment you get up in the morning, and does not :
stop until you get to school. :
---------------------------------------------------'
---------
Visit the Linux Supertore Online: http://www.redcorp.com !
If you want to be deleted from the list, send a mail to
majordomo@rtfm.be with "unsubscribe linux-team" in the body.