Sponsored Content
Full Discussion: Grep out only today's date
Top Forums Shell Programming and Scripting Grep out only today's date Post 302644783 by horhif on Tuesday 22nd of May 2012 12:07:14 PM
Old 05-22-2012
Grep out only today's date

Hi,

I have some log files. I've been asked to grep out error messages that have happened ONLY today. (However, the logs keep messages a long time so they have error messages going back weeks)

They log details in these fields (order):

Month Day Time Server message

I can grep out the month and day. However, on some of the log files....there is 1 space between Month and Day, and on other log files there is 2 spaces.

SO my grep works with the 1 space, but not the 2 space log files.

this is my command:
Code:
cat file_name | cut -d " " -f 1,2

how do i get it to grep out the dates even with 2 spaces between the Month and Time?

Also, i would then like to email out if the date matches today's date....and if not, email out that nothing has changed or been logged today.

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compare today's date with date in a file

Hi I am very new to scripting, Can someone show me how to (in unix shell script) compare the system's date with a date in a file. The requirement is to somehow open this file (which will only have a date in it) and compare it with today's date. If they are equal execute a procedure below but if... (4 Replies)
Discussion started by: siog
4 Replies

2. Shell Programming and Scripting

Get date one month from today

I need to get the date one month in the future from today - or 30 days from today etc... I need this to work all year around - I cannot find anything to solve this issue in the search / faqs etc.... (5 Replies)
Discussion started by: frustrated1
5 Replies

3. Shell Programming and Scripting

grep data lessthan today's date

Hello All, I have a flat file which contains a field with date information. I want to extract the data less than 2 days before without using 'if' Command. ie. Contents from a file like .. Ajay,12-jan-09 rajiv,10-jan-09 Nalini,02-jan-09 Sunil,14-jan-09 Pankaj,11-jan-09 As... (2 Replies)
Discussion started by: ssachins
2 Replies

4. UNIX for Dummies Questions & Answers

Shell Scripts - shows today’s date and time in a better format than ‘date’ (Uses positional paramete

Hello, I am trying to show today's date and time in a better format than ‘date' (Using positional parameters). I found a command mktime and am wondering if this is the best command to use or will this also show me the time elapse since 1/30/70? Any help would be greatly appreciated, Thanks... (3 Replies)
Discussion started by: citizencro
3 Replies

5. Shell Programming and Scripting

Today's date using Perl?

Easiest way to get it in the form of MM/DD/YY for Perl 5.8.8? Thanks (4 Replies)
Discussion started by: stevensw
4 Replies

6. Shell Programming and Scripting

[Solved] Replace yesterday date with today's date except from the first line

Hello, I have a file like this: 2012112920121130 12345620121130msABowwiqiq 34477420121129amABamauee e7748420121130ehABeheheei in case the content of the file has the date of yesterday within the lines containing pattern AB this should be replaced by the current date. But if I use... (3 Replies)
Discussion started by: Lilu_CK
3 Replies

7. Shell Programming and Scripting

UNIX date fuction - how to deduct days from today's date

Hi, One of my Unix scripts needs to look for files coming in on Fridays. This script runs on Mondays. $date +"%y%m%d" will give me today's date. How can I get previous Friday's date.. can I do "today's date minus 3 days" to get Friday's date? If not, then any other way?? Name of the files is... (4 Replies)
Discussion started by: juzz4fun
4 Replies

8. Shell Programming and Scripting

Need to add a date column (today's date) in file

Hi I have file with number status and date1 and date1 field, want add a column today between column date1 and date2. file1.txt number status date1 date2 ===== ==== === ===== 34567 open 27/06/13 28/06/13 45678 open 27/06/13 28/06/13 43567 open 27/06/13 28/06/13 ... (1 Reply)
Discussion started by: vijay_rajni
1 Replies

9. Shell Programming and Scripting

Check, if date is not today

hello, in a file exist entries in date format YYYYMMDD. i want to find out, if there are dates, which isn't today's date. file: date example text 20140714 <= not today's date 20140715 <= not today's date 20140716 <= today's date my idea is to use Perderabo's datecalc ... (2 Replies)
Discussion started by: bora99
2 Replies

10. UNIX for Beginners Questions & Answers

Compare Date to today's date in shell script

Hi Community! Following on from this code in another thread: #!/bin/bash file_string=`/bin/cat date.txt | /usr/bin/awk '{print $5,$4,$7,$6,$8}'` file_date=`/bin/date -d "$file_string"` file_epoch=`/bin/date -d "$file_string" +%s` now_epoch=`/bin/date +%s` if then #let... (2 Replies)
Discussion started by: Greenage
2 Replies
POE::Component::IRC::Plugin::Logger(3pm)		User Contributed Perl Documentation		  POE::Component::IRC::Plugin::Logger(3pm)

NAME
POE::Component::IRC::Plugin::Logger - A PoCo-IRC plugin which logs public, private, and DCC chat messages to disk SYNOPSIS
use POE::Component::IRC::Plugin::Logger; $irc->plugin_add('Logger', POE::Component::IRC::Plugin::Logger->new( Path => '/home/me/irclogs', DCC => 0, Private => 0, Public => 1, )); DESCRIPTION
POE::Component::IRC::Plugin::Logger is a POE::Component::IRC plugin. It logs messages and CTCP ACTIONs to either #some_channel.log or some_nickname.log in the supplied path. In the case of DCC chats, a '=' is prepended to the nickname (like in irssi). The plugin tries to detect UTF-8 encoding of every message or else falls back to CP1252, like irssi (and, supposedly, mIRC) does by default. Resulting log files will be UTF-8 encoded. The default log format is similar to xchat's, except that it's sane and parsable. This plugin requires the IRC component to be POE::Component::IRC::State or a subclass thereof. It also requires a POE::Component::IRC::Plugin::BotTraffic to be in the plugin pipeline. It will be added automatically if it is not present. METHODS
"new" Arguments: 'Path', the place where you want the logs saved. 'Private', whether or not to log private messages. Defaults to 1. 'Public', whether or not to log public messages. Defaults to 1. 'DCC', whether or not to log DCC chats. Defaults to 1. 'Notices', whether or not to log NOTICEs. Defaults to 0. 'Sort_by_date', whether or not to split log files by date, i.e. #channel/YYYY-MM-DD.log instead of #channel.log. If enabled, the date will be omitted from the timestamp. Defaults to 0. 'Strip_color', whether or not to strip all color codes from messages. Defaults to 0. 'Strip_formatting', whether or not to strip all formatting codes from messages. Defaults to 0. 'Restricted', set this to 1 if you want all directories/files to be created without read permissions for other users (i.e. 700 for dirs and 600 for files). Defaults to 1. 'Format', a hash reference representing the log format, if you want to define your own. See the source for details. 'Log_sub', a subroutine reference which can be used to override the file logging. Use this if you want to store logs in a database instead, for example. It will be called with 3 arguments: the context (a channel name or nickname), a type (e.g. 'privmsg' or '+b', and any arguments to that type. You can make use "default_format" to create logs that match the default log format. Note: You must take care of handling date/time and stripping colors/formatting codes yourself. Returns a plugin object suitable for feeding to POE::Component::IRC's "plugin_add" method. "default_format" Returns a hash reference of type/subroutine pairs, for formatting logs according to the default log format. AUTHOR
Hinrik Oern Sigur`sson, hinrik.sig@gmail.com perl v5.14.2 2011-12-07 POE::Component::IRC::Plugin::Logger(3pm)
All times are GMT -4. The time now is 04:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy