Bonjour, j´ai un petit projet perso mais je bute avec sed.
J´ai le code suivant
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
#!/bin/sh
# Recherche ip actuel
check_ip="1.2.3.4"
check_new=`grep -oP 'NEW=\K.*' ip_current.txt`
 
#Creation fichier ip_current.txt si n´existe pas
if [ -e ip_current.txt ]
then
    touch ip_current.txt
fi
#check ips en ip_current.txt
if [ $check_ip  != $check_new ]; then
    echo "IP Differente"
    echo "NEW=$check_ip" > ip_current.txt
    echo "OLD=$check_new" >> ip_current.txt
    sed 's/NEW=$check_new/NEW=$check_ip/g' ip_current.txt
 
    #sed 's/NEW=$check_new/NEW=$check_ip/g' /volume1/@appstore/DNSServer/named/etc/zone/master/local
    sed 's/OLD=\K.*/$check_ip/g' ./volume1/@appstore/DNSServer/named/etc/zone/master/local
 
 
else
    echo "Pas de changement de IP"
fi
C´est le sed suivant qui pose probleme :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
sed 's/OLD=\K.*/$check_ip/g' ./volume1/@appstore/DNSServer/named/etc/zone/master/local
Il ne trouve pas le fichier "local", donc je me demande comment placer cette commande pour effectuer l´action.
Merci