OVH Cloud OVH Cloud

substitution dans des fichiers

24 réponses
Avatar
Nicolas Pontoizeau
Bonjour,

J'ai fait un menu pour un site web et maintenant je souhaite recopier ce
menu sur toutes les pages de mon site.

Existe-t-il un moyen pour copier tout ce qui se trouve entre les
commentaires :

<!-- here starts the menu-->

<div id="topmenu">

<div id="menu">
[...]
</div><!--menu-->
</div><!--topmenu-->

<!-- here end the menu-->

et de mettre à jour tout le contenu des pages du site entre les
commentaires :
<!-- here starts the menu-->
[...]
<!-- here end the menu--> ?

J'ai pensé à perl car ça ressemble à :
for i in *.htm; do perl -pe "s/htm/php/g" -i $i; done
qui me permet de remplacer html par php mais là c'est un plus complexe
et je connais très mal perl.

Merci d'avance,

--
http://www.nicolas.pontoizeau.org/
Nicolas Pontoizeau - Promotion EFREI 2005

4 réponses

1 2 3
Avatar
Nicolas George
Nicolas Pontoizeau wrote in message
<slrnd60fhd.vns.pontoize*NOSPAM*@choam.unix.efrei.fr>:
Content-Type: text/plain; charset=iso-8859-1

Merci je jeterai un ½il.
^

Attention, tu as un problème de configuration, ceci est un 1/2 et pas un oe.

Avatar
Nicolas Pontoizeau
Nicolas Pontoizeau wrote in message
<slrnd60fhd.vns.pontoize*NOSPAM*@choam.unix.efrei.fr>:
Content-Type: text/plain; charset=iso-8859-1

Merci je jeterai un ½il.
^

Attention, tu as un problème de configuration, ceci est un 1/2 et pas un oe.


Hum c'était une ligature (e dans l'o) mais ça n'existe pas dans l'iso88591
si mes souvenir sont bons donc mon text est encodé en iso885915. En fait
un peu compliqué pour moi de savoir si ça passe car je poste en utf-8
sur un machine qui elle n'a pas la locale (pas pratique du tout).

Merci pour l'info.

--
http://www.nicolas.pontoizeau.org/
Nicolas Pontoizeau - Promotion EFREI 2005


Avatar
DoMinix
Nicolas Pontoizeau wrote:

$CODE n'est pas interpreté par le shell a cause de <'>
essaye cela
#!/bin/bash
perl -p00i~ -e 'BEGIN{CODE=`cat menu.txt`};s/<!-- here starts the


OOPS ^manque "$" la



perl -p00i~ -e 'BEGIN{$CODE=`cat menu.txt`};s/<!-- here starts the menu-->.*<!-- here end the menu-->/$CODE/gm' svc_bdrp.html

Je sais pas si tu as tester mais chez moi ça marche pas.



perl -p00 -e 'BEGIN{$CODE=`cat menu.txt`};s/<!-- here starts the
menu-->.*<!-- here end the menu-->/$CODE/gs' page.txt

j'ai testé et ca marche, j'ma fourré entre le /m et /s des regex,
un classique celui la.

--
dominix



Avatar
Nicolas Pontoizeau
perl -p00 -e 'BEGIN{$CODE=`cat menu.txt`};s/<!-- here starts the
menu-->.*<!-- here end the menu-->/$CODE/gs' page.txt

j'ai testé et ca marche, j'ma fourré entre le /m et /s des regex,
un classique celui la.


Pareil marche nickel chez moi aussi. Merci

--
http://www.nicolas.pontoizeau.org/
Nicolas Pontoizeau - Promotion EFREI 2005

1 2 3