Précédent   Forum des professionnels en informatique > Systèmes > Linux > Applications > Shell
Shell Vos questions sur l'utilisation des commandes shell
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 21/04/2011, 20h52   #1
Membre habitué
 
Homme David
Étudiant
Inscription : avril 2009
Messages : 284
Détails du profil
Informations personnelles :
Nom : Homme David
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : avril 2009
Messages : 284
Points : 134
Points : 134
Par défaut [QST]trouver une ligne et rajouter à celle-ci

Bonjour a tous

je cherche a modifier une ligne dans mon httpd.conf (apache).
Code :
1
2
3
4
 
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
En faite je souhaiterai ajouter a la ligne DirectoryIndex, index.php.
En gros obtenir ceci

Code :
1
2
3
4
 
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
j'ai bien pensé a faire cela avec un sed , mais je n'y arrive pas ....

Savez vous comment faire ceci ?

Je vous remercie d'avance pour votre aide
hannibal.76 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/04/2011, 09h09   #2
Membre Expert
 
Homme Alexis
Intégrateur d'Exploitation
Inscription : février 2003
Messages : 876
Détails du profil
Informations personnelles :
Nom : Homme Alexis
Âge : 32
Localisation : France

Informations professionnelles :
Activité : Intégrateur d'Exploitation
Secteur : Biens de consommation

Informations forums :
Inscription : février 2003
Messages : 876
Points : 1 619
Points : 1 619
Envoyer un message via ICQ à Alek-C Envoyer un message via Skype™ à Alek-C
Salut,

une solution :
Code :
1
2
3
4
5
6
7
8
$ cat httpd.conf
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
$ sed 's/DirectoryIndex index.html$/& index.php/' httpd.conf
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
Alek-C est déconnecté   Envoyer un message privé Réponse avec citation 11
Vieux 22/04/2011, 09h09   #3
Membre Expert
 
Avatar de becket
 
Frédéric Brugmans
Informaticien multitâche
Inscription : février 2005
Messages : 661
Détails du profil
Informations personnelles :
Nom : Frédéric Brugmans

Informations professionnelles :
Activité : Informaticien multitâche

Informations forums :
Inscription : février 2005
Messages : 661
Points : 1 196
Points : 1 196
Code :
1
2
 
 awk  ' { if ( $0 ~ /DirectoryIndex/ ) { $0 = $0 " index.php " } print $0 } '
Code :
1
2
 
sed -e 's/\(DirectoryIndex.*\)/\1 index.php/g'
becket est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 22/04/2011, 11h21   #4
Membre habitué
 
Homme David
Étudiant
Inscription : avril 2009
Messages : 284
Détails du profil
Informations personnelles :
Nom : Homme David
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : avril 2009
Messages : 284
Points : 134
Points : 134
merci, tous vos codes fonctionnent

il va vraiment falloir que j'apprenne bien le awk

encore merci
hannibal.76 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 12h33.


 
 
 
 
Partenaires

Hébergement Web