Hallo, ich nochmal.
Ich habe mit sed jetzt etwas experimentiert und für ein Vorhaben habe ich diesen Code:
1 | sed -i "/OPEN_TCP=\"/ s//&$FTP_PORT,/" /root/firewall.conf |
Alternativ diesen:
1 | sed -i "s/OPEN_TCP=\"/OPEN_TCP=\"$FTP_PORT,/g" /root/firewall.conf |
Nun habe ich aber das Problem, dass in der File z.b. auch das vorkommt:
LAN_OPEN_TCP=""
LAN_HOST_OPEN_TCP=""
LAN_INET_OPEN_TCP=""
etc.
OPEN_TCP ist das letzte "OPEN_TCP" welches im Dokument vorkommt.
Mein obiger Code macht aber das aus den Zeilen
LAN_OPEN_TCP="22,"
LAN_HOST_OPEN_TCP="22,"
LAN_INET_OPEN_TCP="22,"
Das möchte ich aber nicht. Jemand eine Idee, wie man das bewerkstelligen kann?