methomas
Goto Top

Logdatein filter - vi?

Ich suche ein Editor/Tool bzw. den dazu passenden Befehl. Ich möchte von Logdateien nur bestimmte Zeile angezeigt (oder als tmp-Datei) bekommen. Beispiel bei einer Apache Logfile, ich möchte nur alle Zeilen sehen, welche

string "87.x.x.x" und string "example.html" enhält

oder

string "87.x.x.x" aber nicht string ".gif" enhält

Wie macht ihr das? Vermute das geht schon fix mit boardmitteln wie VI. Kann mir jemand den Syntax verraten oder ein tool empfehlen?

Content-Key: 257733

Url: https://administrator.de/contentid/257733

Printed on: April 24, 2024 at 19:04 o'clock

Member: Lochkartenstanzer
Solution Lochkartenstanzer Dec 16, 2014 updated at 12:52:38 (UTC)
Goto Top
Zitat von @methomas:


string "87.x.x.x" und string "example.html" enhält

oder

string "87.x.x.x" aber nicht string ".gif" enhält


Mit cat, grep und less?

lks

PS: Unix grep regex containing 'x' but not containing 'y'
Member: colinardo
Solution colinardo Dec 16, 2014 updated at 12:52:33 (UTC)
Goto Top
Moin,
wie lks schon sagt, grep ist dein Freund:
cat /var/log/apache2/access.log | grep -ei '87\.x\.x\.x' | grep -ei 'example\.html'
Grüße Uwe
Member: methomas
methomas Dec 16, 2014 updated at 12:57:40 (UTC)
Goto Top
Danke lks und Uwe,

hatte mich irgendwie schon auf vi eingeschossen.

Nach lks Beitrag, hatte ich mir dann schon diese Lösung gebastelt

grep '87.x.x.x' file | grep -v '.gif' > newfile