Hello, I like to get out of a log file all lines which are from 08.12.2002 *and* have the user 'michael' grep 08.12.2002 /filename does the first half, how can I include there the grep for 'michael' ?? Thx Micha :-)) [..] 07.12.2002 19:41:49 21 2324 10773 0 1.0 michael 07.12.2002 19:42:49 21 2324 10773 0 1.0 michael 08.12.2002 19:43:49 21 2324 10773 0 1.0 michael 08.12.2002 19:44:49 21 2324 10773 0 1.0 michael 08.12.2002 19:45:49 21 2324 10773 0 1.0 tst 08.12.2002 19:46:49 21 2324 10773 0 1.0 tst [..]
You can re-filter the output via a second grep. For example: cat filename.txt | grep 08.12.2002 | grep michael On Sunday 08 December 2002 21:45, Michael Hoeller wrote:
Hello,
I like to get out of a log file all lines which are from 08.12.2002 *and* have the user 'michael'
grep 08.12.2002 /filename does the first half, how can I include there the grep for 'michael' ??
Thx Micha :-))
[..] 07.12.2002 19:41:49 21 2324 10773 0 1.0 michael 07.12.2002 19:42:49 21 2324 10773 0 1.0 michael 08.12.2002 19:43:49 21 2324 10773 0 1.0 michael 08.12.2002 19:44:49 21 2324 10773 0 1.0 michael 08.12.2002 19:45:49 21 2324 10773 0 1.0 tst 08.12.2002 19:46:49 21 2324 10773 0 1.0 tst [..]
-- To err is human, but to forgive is beyond the scope of the Operating System... Αλέξανδρος Καρυπίδης Πανεπιστήμιο Θεσσαλίας Τμήμα Μηχ/κών Η/Υ, Τηλεπικοινωνιών & Δικτύων Alexandros Karypidis University of Thessaly Computer & Communications Engineering dept.
* Alexandros Karypidis <karypid@inf.uth.gr> [12-08-02 14:48]:
You can re-filter the output via a second grep. For example:
cat filename.txt | grep 08.12.2002 | grep michael
On Sunday 08 December 2002 21:45, Michael Hoeller wrote:
I like to get out of a log file all lines which are from 08.12.2002 *and* have the user 'michael'
grep 08.12.2002 /filename does the first half, how can I include there the grep for 'michael' ??
[..] 07.12.2002 19:41:49 21 2324 10773 0 1.0 michael 07.12.2002 19:42:49 21 2324 10773 0 1.0 michael 08.12.2002 19:43:49 21 2324 10773 0 1.0 michael 08.12.2002 19:44:49 21 2324 10773 0 1.0 michael 08.12.2002 19:45:49 21 2324 10773 0 1.0 tst 08.12.2002 19:46:49 21 2324 10773 0 1.0 tst [..]
Or, getting past the TOFU and extraneous quoting: grep 08.12.2002 filename.xxx | grep michael -- Patrick Shanahan Registered Linux User #207535 @ http://counter.li.org icq#173753138
On Sun, Dec 08, 2002 at 08:45:02PM +0100, Michael Hoeller wrote:
Hello,
I like to get out of a log file all lines which are from 08.12.2002 *and* have the user 'michael'
grep 08.12.2002 /filename does the first half, how can I include there the grep for 'michael' ??
grep '^08\.12\.2002.*michael' <file name> Victor
The 02.12.08 at 20:45, Michael Hoeller wrote:
I like to get out of a log file all lines which are from 08.12.2002 *and* have the user 'michael'
From "info grep":
10. I can do OR with `|', but what about AND? grep 'paul' /etc/motd | grep 'franc,ois' finds all lines that contain both `paul' and `franc,ois'. -- Cheers, Carlos Robinson
On Sun, 08 Dec 2002, Michael just had to get this off his chest:
Hello,
I like to get out of a log file all lines which are from 08.12.2002 *and* have the user 'michael'
grep 08.12.2002 /filename does the first half, how can I include there the grep for 'michael' ??
Thx Micha :-))
[..] 07.12.2002 19:41:49 21 2324 10773 0 1.0 michael 07.12.2002 19:42:49 21 2324 10773 0 1.0 michael 08.12.2002 19:43:49 21 2324 10773 0 1.0 michael 08.12.2002 19:44:49 21 2324 10773 0 1.0 michael 08.12.2002 19:45:49 21 2324 10773 0 1.0 tst 08.12.2002 19:46:49 21 2324 10773 0 1.0 tst [..]
$ grep '\(8.12.2002\).*michael' logfile 08.12.2002 19:43:49 21 2324 10773 0 1.0 michael 08.12.2002 19:44:49 21 2324 10773 0 1.0 michael $ awk '/(08.12.2002).*michael/ {print}' logfile 08.12.2002 19:43:49 21 2324 10773 0 1.0 michael 08.12.2002 19:44:49 21 2324 10773 0 1.0 michael Theo -- Theo v. Werkhoven Registered Linux user# 99872 http://counter.li.org ICBM 52 13 27N , 4 29 45E. SuSE 8.0 x86 Kernel k_Athlon 2.4.19-4GB See headers for PGP/GPG info.
participants (8)
-
Alexandros Karypidis
-
Carlos E. R.
-
MichaelHoeller@t-online.de
-
Richard Bos
-
sjb
-
SuSEnixER
-
Theo v. Werkhoven
-
Victor R. Cardona