Bonjour tout le monde,
Je galère un max ainsi je viens en quête d'aide bienveillante...

J'ai un fichier qui ressemble à ceci :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
Fonction
Fonction
save_extra_interface_config()
{
 
        assert_arguments device
 
        [ "$slave" ] && return
 
        ! is_ipv6 || warn "Extra interfaces not supported on IPv6" || return 0
 
        local dir="/tmp"
        rm -rf "$dir.backup" 2>/dev/null
        [ ! -d "$dir" ] || mv $dir $dir.backup
        mkdir -p  $dir || fail "Failed to create $dir"
 
        local scriptdir="/etc/sysconfig/network-scripts"
        local check_exceptions="false"
        if [ -e /opt/toto/ha/conf.d/network.conf ]; then
                check_exceptions="true"
for ifcfg in $scriptdir/ifcfg-e* $bondintf; do
                local dev=${ifcfg#$scriptdir/ifcfg-}
                local local_dev="false"
   }
 
Other function
Other function
Other function
restore_extra_interface_config()
{
for ifcfg in $scriptdir/ifcfg-e* $bondintf; do
 
}
Je cherche à remplacer le $scriptdir/ifcfg-e* $bondintf par toto (par exemple) de la fonction save_extra_interface_config (ligne 22 uniquement et pas la ligne 32)

Voyez-vous comment faire cela svp ?

Pour ma part, la commande :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
awk '/save_extra_interface_config\(\)/','/\}/' MonFichier
Me retourne la fonction en entier

La commande :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
sed -i -e 's/.*for ifcfg in \$scriptdir\/ifcfg-e\* \$bondintf; do.*/MonFichier/g'
Fait le bon remplacement.

Seulement, si je fais ce sed sur le fichier, il remplace tout. J'aimerais ainsi pouvoir faire ce sed sur le résultat de mon awk. Voyez-vous comment faire cela SVP ?

D'avance, merci pour votre aide.