Get end of a log file from a certain point/date

Get end of a log file from a certain point/date

Post by kia.. » Thu, 02 Nov 2000 17:54:44



I would like to get the last part of a log file (text format only),
everything since a certain date/time and until the end. I could do this in
Perl, but I prefer using as simple/small tools as possible. "tail -n" sounds
right, but what is a quick way to get the first line that starts with a
certain date? I am looking for something I can easily type from command
prompt at any UNIX.

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Get end of a log file from a certain point/date

Post by Simo » Thu, 02 Nov 2000 18:41:48


Quote:> I would like to get the last part of a log file (text format only),
> everything since a certain date/time and until the end. I could do
this in
> Perl, but I prefer using as simple/small tools as possible. "tail -n"
sounds
> right, but what is a quick way to get the first line that starts with
a
> certain date? I am looking for something I can easily type from
command
> prompt at any UNIX.

grep -n -e "Oct 31"

Will give you the line numbers, extract the first one.

wc -l <filename>

Will give the total number of lines in the file.

tail -n (total - first_line)

You should be able to build a shell script with these.

Have fun.

--
Simon
-----

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Get end of a log file from a certain point/date

Post by Chuck Dillo » Thu, 02 Nov 2000 23:52:34


How about:

sed '/<date pattern>/,$p;d' <logfile>

-- ced


> I would like to get the last part of a log file (text format only),
> everything since a certain date/time and until the end. I could do this in
> Perl, but I prefer using as simple/small tools as possible. "tail -n" sounds
> right, but what is a quick way to get the first line that starts with a
> certain date? I am looking for something I can easily type from command
> prompt at any UNIX.

> Sent via Deja.com http://www.deja.com/
> Before you buy.

--
Chuck Dillon
Senior Software Engineer
Genetics Computer Group, a subsidiary of Pharmacopeia, Inc.
 
 
 

Get end of a log file from a certain point/date

Post by Brian Huntle » Thu, 02 Nov 2000 23:58:02




> I would like to get the last part of a log file (text format only),
> everything since a certain date/time and until the end. I could do
this in
> Perl, but I prefer using as simple/small tools as possible. "tail -n"
sounds
> right, but what is a quick way to get the first line that starts with
a
> certain date? I am looking for something I can easily type from
command
> prompt at any UNIX.

man csplit. It'll do what you want.

Specifially, try
X=$$;csplit  -sf ${X} /var/adm/messages %"Oct 30"%;cat ${X}00;rm ${X}00

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Get end of a log file from a certain point/date

Post by Brian Huntle » Fri, 03 Nov 2000 01:23:12




Quote:

> How about:

> sed '/<date pattern>/,$p;d' <logfile>

The problem with that is <date pattern> is like <insert magic here>,
since many log files use a "Oct 31" type date, and a pattern that
matches everything after that (Nov   1,... Nov 30, etc.) and nothing
before is tricky to say the least.

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Get end of a log file from a certain point/date

Post by Chuck Dillo » Fri, 03 Nov 2000 02:26:07





> > How about:

> > sed '/<date pattern>/,$p;d' <logfile>

> The problem with that is <date pattern> is like <insert magic here>,
> since many log files use a "Oct 31" type date, and a pattern that
> matches everything after that (Nov   1,... Nov 30, etc.) and nothing
> before is tricky to say the least.

It only has to match the first occurance nothing more.  It says print
the range from an occurance of a given pattern to the end of the file.
It doesn't matter what is in the lines following the matched line.

-- ced

--
Chuck Dillon
Senior Software Engineer
Genetics Computer Group, a subsidiary of Pharmacopeia, Inc.

 
 
 

Get end of a log file from a certain point/date

Post by Brian Huntle » Fri, 03 Nov 2000 04:14:17







> > > How about:

> > > sed '/<date pattern>/,$p;d' <logfile>

> > The problem with that is <date pattern> is like <insert magic here>,
> > since many log files use a "Oct 31" type date, and a pattern that
> > matches everything after that (Nov   1,... Nov 30, etc.) and nothing
> > before is tricky to say the least.

> It only has to match the first occurance nothing more.  It says print
> the range from an occurance of a given pattern to the end of the file.
> It doesn't matter what is in the lines following the matched line.

> -- ced

Whoops, sorry Chuck, I misread your posting. You are correct, of course,
and in a nice elegant way. I'll archive that 1-liner.

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Get end of a log file from a certain point/date

Post by Simo » Fri, 03 Nov 2000 18:07:45


Quote:> You are correct, of course,
> and in a nice elegant way. I'll archive that 1-liner.

Thanks guys for a good lesson ! Obviously still a newbie here !

--
Simon
-----

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Get end of a log file from a certain point/date

Post by kia.. » Sat, 04 Nov 2000 17:49:39


Thanks, this looks like it does what I need in a sufficiently generic manner.
I also found that some versions of grep have switches "-A" and "-B", but it
is not supported across all versions. "sed" is probably more uniform. Now
I'll just have to find convenient ways of matching different datetime formats
in different logfiles (including those using slashes as separators), but
that's a different story...

Thank to everybody for suggestions!



> How about:

> sed '/<date pattern>/,$p;d' <logfile>

> -- ced


> > I would like to get the last part of a log file (text format only),
> > everything since a certain date/time and until the end. I could do this in
> > Perl, but I prefer using as simple/small tools as possible. "tail -n" sounds
> > right, but what is a quick way to get the first line that starts with a
> > certain date? I am looking for something I can easily type from command
> > prompt at any UNIX.

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

> --
> Chuck Dillon
> Senior Software Engineer
> Genetics Computer Group, a subsidiary of Pharmacopeia, Inc.

Sent via Deja.com http://www.deja.com/
Before you buy.
 
 
 

1. wierd stuffs in proxy log file and back end server log file

OH, folks,

I have 5 apache 1.3.19 under linux totally. One is for proxy and 4
others are backend servers.

I have for instance, over 400 requests concurrently sending from 4
different clients to the proxy.

 Sometimes, the proxy log file has the error messages like:
Connection refused: proxy connect to xxx (IP of a backend server) port
80 failed. or sometimes, it is not port 80, it is port 8 or 808,
something like that. But I do not have these port number in my rewrite
engine or in the conf file. I only deal with 8080. It seems that it
only happens when it deals with large concurrent requests.

Also, in the backend server, sometimes, it will say: file not exist:
/serverroot/apache/htdocs/some wierd string /somefile exists .
Definitely it is not found since it adds some wierd string in the
middle. Those wierd strings seem to be some substring from the
request,for instance, http://xxx. It does not always happens.

Can anyone tells me what is going on? Thanks

Jenny

2. linux nukes my clock

3. Setmentation Fault in only when controled recursive loop gets too certain point

4. IP Masquerading Redhat 6.1 diald wvdial

5. How to get the date of a certain date

6. BMRT - prblems

7. Preventing certain files on mount points?.

8. Default font !?!

9. How to get the Week Start Date and End Date

10. how to mv files of certain date to other dir?

11. find command to find files of a certain date

12. How to test if a file has been modified since a certain date?

13. Transforming log file into separate files based on date?