
Ich suche nach einer eleganten Lösung, die diese beiden Befehle kombiniert:
sed -i '/Y/! s/replace/with/' /path/to/file
sed -i '/X/ s/replace/with/' /path/to/file
Ich habe es versucht
sed -i '/X/ /Y/! s/replace/with/' /path/to/file
was nicht funktioniert. Gibt es dafür eine elegante Lösung?
Antwort1
So etwas wie sed '/X/ {/Y/! s/replace/with/}'
vielleicht?
$ sed '/X/ {/Y/! s/replace/with/}' << EOF
X replace X
X replace Y
Y replace X
Y replace Y
EOF
X with X
X replace Y
Y replace X
Y replace Y