
Hullos zusammen, versuche mich grade erstmalig an sed. Mein Ziel ist es, eine Datei nach dem Wort "HSL" zu durchforsten und alle Zeilen zu löschen, in denen das vorkommt. sed -n /HSL/p datei # zeigt mir alle Zeilen an, supi! sed -n /HSL/d datei # macht leider gar nix Also genau so stand das Beispiel in meiner Buchquelle. Kann mir einer nen Hint geben, was ich falsch verstanden hab? (Ich hab Schreibrechte auf die Datei, sie gehört root, der sed wird von root ausgeführt). Thx, Bernd -- One OS to rule them all, one OS to find them. One OS to bring them all, and in the darkness bind them In the land of Redmond, where the shadows lie.

Und nochmal ich, Am Dienstag, 29. Juli 2003 12:57 schrieb Stefan Eggert:
Hmm, nope. Logs eines proprietären (richtig geschrieben ??) SMSC-Protokolls.
sed -e /HSL/d File
Tja, ihr habt mir beide das Gleiche geschickt. Ich habs versucht, es ändert aber nix. Die Zeilen sind noch immer in der Datei. Er meckert auch nicht, scrollt das gesamte Log in Windeseile über meinen Bildschirm, aber hinterher sind immer noch Alle "HSL-Zeilen" drin. Any ideas? Bernd -- One OS to rule them all, one OS to find them. One OS to bring them all, and in the darkness bind them In the land of Redmond, where the shadows lie.

Hullos, Am Dienstag, 29. Juli 2003 13:16 schrieb Dominik Wuttke:
gesagt, getan....hat leider auch nx verändert. *sich am Kopf kratz* Bernd Doch ein rechte-Problem? Meckern tut er nicht? -- One OS to rule them all, one OS to find them. One OS to bring them all, and in the darkness bind them In the land of Redmond, where the shadows lie.

Am Dienstag, 29. Juli 2003 13:23 schrieb Sven Schupp:
Okay, das macht Sinn:) Hatte das vorher schonmal so mit der -n Option versucht, hatte nicht geklappt. Hätts direkt nochmal so mit -e probieren sollen, hab nicht dran gedacht. Thx für alle Antworten, Bernd -- One OS to rule them all, one OS to find them. One OS to bring them all, and in the darkness bind them In the land of Redmond, where the shadows lie.

Ich beantworte sed-Fragen gerne mit perl-Antworten ;-) Also mit perl machste einfach perl -i.bak -ne 'print unless /HSL/' Wenn Du sicher bist, daß Du die backup Datei nicht brauchst. läßt Du einfach das -i.bak weg. -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -------------------------------------------------- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post

On Tue, 29 Jul 2003 at 13:38 +0200, Stephan Hradek wrote:
Nein, nur das .bak, also: perl -i -ne 'print unless /HSL/' DATEINAME Ohne -i wird ja wieder nur ausgegeben und nicht die Datei verändert. Eilert -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Eilert Brinkmann -- Universitaet Bremen -- FB 3, Informatik eilert@informatik.uni-bremen.de - eilert@tzi.org http://www.informatik.uni-bremen.de/~eilert/

* Bernd Tannenbaum schrieb am 29.Jul.2003:
sed ändert auch nichts an der Datei. Nie. sed schickt nur was auf die Ausgabe. Die kannst Du ja in eine Datei umlenken und anschließend umbenennen. Wichtig ist hier das anschließend. Niemals in die gleiche Datei umlenken, sonst überschreibt sie sich selber. Bernd -- Bitte die Etikette beachten: http://www.suse-etikette.de.vu/etikette.html Bitte Realnamen angeben, kein Vollquoting, kein Html, PGP oder Visitenkarten benutzen. Signatur mit "-- " abtrennen, bei Antworten "Re: " voranstellen, sonst nichts. |Zufallssignatur 4

Hy, * Bernd Tannenbaum schrieb am 29.Jul.2003:
ich habe ein Script laufen was so etwas aenliches macht. Eventuell hilft dir das ja. #alle zeilen in den org.txt vorkommt werden geloescht sed '/org\.txt/d' org.txt > org_lager.txt rm org.txt mv org_lager.txt org.txt .................................. Gruß, Normen

Bernd Tannenbaum <tannenbaum@service.itenos.de>
sed -n /HSL/p datei # zeigt mir alle Zeilen an, supi! sed -n /HSL/d datei # macht leider gar nix
1. sed liest stdin und schreibt stdout. 2. Generell ein Programm liest und schreibt eine Datei i.d.R nicht gleichzeitig. 3. sed -n -n By default, sed will print out the pattern space at the end of each cycle through the script. These options disable this automatic printing, and sed will only produce output when explicitly told to via the p command. -n zeigt nur die Zeilen an, die explizit per sed Kommando p ausgegeben werden. -n /HSL/p ^ ^-------------------------+ |---------- nur anzeigen was mit p gedruckt wird hier werden also alle Zeile angezeigt, welche HSP enthalten 4. -n /HSL/d ^-- lösche Zeile aber zeige nichts an (da kein p) 5. Richtig wäre also: sed -e'/HSL/d' datei > neue-datei oder auch: grep -v "HSL" datei > neue-datei 6. Der "Form halber" -e"sed-kommand" Mehr dazu: man sed man grep Jürgen -- Dr.rer.nat. Juergen Vollmer, Viktoriastrasse 15, D-76133 Karlsruhe Tel: +49(721) 9204871 Fax: +49(721) 24874 juergen.vollmer@[informatik-vollmer.de|alumni.uni-karlsruhe.de|acm.org] www.informatik-vollmer.de

Und nochmal ich, Am Dienstag, 29. Juli 2003 12:57 schrieb Stefan Eggert:
Hmm, nope. Logs eines proprietären (richtig geschrieben ??) SMSC-Protokolls.
sed -e /HSL/d File
Tja, ihr habt mir beide das Gleiche geschickt. Ich habs versucht, es ändert aber nix. Die Zeilen sind noch immer in der Datei. Er meckert auch nicht, scrollt das gesamte Log in Windeseile über meinen Bildschirm, aber hinterher sind immer noch Alle "HSL-Zeilen" drin. Any ideas? Bernd -- One OS to rule them all, one OS to find them. One OS to bring them all, and in the darkness bind them In the land of Redmond, where the shadows lie.

Hullos, Am Dienstag, 29. Juli 2003 13:16 schrieb Dominik Wuttke:
gesagt, getan....hat leider auch nx verändert. *sich am Kopf kratz* Bernd Doch ein rechte-Problem? Meckern tut er nicht? -- One OS to rule them all, one OS to find them. One OS to bring them all, and in the darkness bind them In the land of Redmond, where the shadows lie.
participants (9)
-
B.Brodesser@t-online.de
-
Bernd Tannenbaum
-
Dominik Wuttke
-
Eilert Brinkmann
-
Jürgen Vollmer
-
Normen Dommaschk
-
Stefan Eggert
-
Stephan Hradek
-
Sven Schupp