CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Open last n minutes of log file using cat



Mar 7, 2016, 9:16 AM

Post #1 of 2 (3333 views)
Open last n minutes of log file using cat Can't Post

Hello Gurus,

Is it possible to cat a log file in perl to get the last n minutes of a file.

a similar solution using awk is

cat 17 |awk -v d1="$(date --date="-2 min" "+%b %_d %H:%M")" -v d2="$(date "+%b %_d %H:%M")" '$0 > d1 && $0 < d2 || $0 ~ d2'

looking for an alternative using perl syntax

appreciate the assistance

Veteran / Moderator

Mar 7, 2016, 3:38 PM

Post #2 of 2 (3323 views)
Re: [new2perl2016] Open last n minutes of log file using cat [In reply to] Can't Post

Please post a reasonable sample of the logfile for us to test.

How big is the log file?

Do you have a perl script that you're testing? If so, please post it along with any/all error messages it might be producing.

What's your level of perl knowledge? Since you posted this question in the Intermediate section, we must assume that you have some perl experience.

(This post was edited by FishMonger on Mar 7, 2016, 3:39 PM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives