Sie brauchen Hilfe. Ich war auf der Suche nach einem ganzen Tag ohne eine Lösung zu finden, die speziell auf meine Bedürfnisse zugeschnitten ist.Suchen und Linien in der Datei auf String basierend löschen, aber letzte Vorkommen halten
In einer Datei:
Lots
of
other
lines
...
...
# [email protected] ..........1323 <- Do not include '# Client=HOSTNAME'
# [email protected] ..........123123 <- Do not include '# Client=HOSTNAME'
[email protected] ....rndChars.... <- delete line
[email protected] ....rndChars.... <- delete line
[email protected] ....rndChars.... <- delete line
[email protected] ....rndChars.... <- delete line
[email protected] ....rndChars.... <- keep last occurrence
[email protected] ....rndChars.... <- keep last occurrence
[email protected] ....rndChars.... <- delete line
[email protected] ....rndChars.... <- delete line
[email protected] ....rndChars.... <- keep last occurrence
...
...
more
lines
Ich brauche alle Zeilen passend zu finden „Client =“ oder mehr und löschen Sie die Linien mit Ausnahme des letzten Auftretens. Problem ist, ich weiß nie, wie der Hostname sein wird.
Ausgang sollte sein:
Lots
of
other
lines
...
...
# [email protected] ..........1323 <- Do not include '# Client=HOSTNAME'
# [email protected] ..........123123 <- Do not include '# Client=HOSTNAME'
[email protected] ....rndChars.... <- keep last occurrence
[email protected] ....rndChars.... <- keep last occurrence
[email protected] ....rndChars.... <- keep last occurrence
...
...
more
lines
Thx im Voraus.
Was haben Sie bisher versucht? –