Grep the logfile for sysdate-1


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep the logfile for sysdate-1
# 1  
Old 10-20-2014
Grep the logfile for sysdate-1

Looking for help.
I need help in the grep ( alternative) to filter out the a keyword from the logfile for a time period of sysdate -1.

My logfile looks like:

Code:
####<Sep 7, 2014 3:46:55 PM PDT>  <Warning> <Management>  <hostname>  <> <[ACTIVE]  ExecuteThread: 
####<Sep 15, 2014 2:51:05 AM PDT> <Warning> <Management> <hostname> <> <[ACTIVE] ExecuteThread: 
####<Oct 10, 2014 3:57:45 AM PDT> <Warning> <Management> <hostname> <> <[ACTIVE] ExecuteThread: 
####<Oct 10, 2014 4:21:57 AM PDT> <Warning> <Management> <hostname> <> <[ACTIVE] ExecuteThread: 
####<Oct 13, 2014 4:00:04 PM PDT> <Warning> <Management> <hostname> <> <[ACTIVE] ExecuteThread: 
####<Oct 13, 2014 4:01:49 PM PDT> <Warning> <Management> <hostname> <> <[ACTIVE] ExecuteThread:
####<Oct 13, 2014 4:17:04 PM PDT> <Warning> <Management> <hostname> <> <[ACTIVE] ExecuteThread:

Something like :

Code:
cat abc.log |grep -i error ( but with results of the last 1 day only)

Thanks guys in advance
# 2  
Old 10-20-2014
Depending on the system (which you fail to mention) you use, esp. the date command, this might work:
Code:
grep -i "$(date +"%b %_d" -d"-1day").*error" abc.log

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logfile monitoring with logfile replacement

Bonjour, I've wrote a script to monitor a logfile in realtime. It is working almost perfeclty except for two things. The script use the following technique : tail -fn0 $logfile | \ while read line ; do ... some stuff done First one, I'd like a way to end the monitoring script if a... (3 Replies)
Discussion started by: Warluck
3 Replies

2. UNIX for Dummies Questions & Answers

Inserting sysdate into the XML!!

How do i insert the sysdate in the below xml file? This has to happen dynamically, meaning everytime the script runs, it shud put 2 sysdates in the below xml marked in red ...format is YYYY-MM-DD <?xml version="1.0" encoding="UTF-8"?> <Package> <LOCALE>en_US</LOCALE> <User... (2 Replies)
Discussion started by: saggiboy10
2 Replies

3. Shell Programming and Scripting

Not able to grep a particular message in logfile.

Hi I am not able to grep a message in a log file - For ex - Notice < > "Server1" is in deploying state under "Stut" domain When i use gzcat logfile | grep -i " Notice < > "Server1" is in deploying state under "Stut" domain" It is not returning any value. Is it because of "Server1"... (1 Reply)
Discussion started by: honey26
1 Replies

4. Shell Programming and Scripting

Need to Grep or awk a logfile for greater than value

Hello all Hoping someone would be kind enough to suggest a solution to a problem i have, and see if maybe i can even do this without a script. Essentially i have a very large log file, and within it each line had a value called TTMT, and it records a variable number in the following way, so... (6 Replies)
Discussion started by: 1905
6 Replies

5. Shell Programming and Scripting

Sysdate setting in .profile

Hi, I need to append the current system date and time in my file which are being taken a backup by my shell script .so i added the following line in by .profile SYSDATE="$( date '+%d/%B/%Y/%S' )" export SYSDATE But it's a constant one rather then a sync with my system date ,so how can i do... (10 Replies)
Discussion started by: malickhat
10 Replies

6. UNIX for Dummies Questions & Answers

Rename FILE with sysdate-1

Hi, There is file on UNIX server named as fd40568-07082009.txt which get FTP'ed to UNIX on a daily basis. 07082009 of fd40568-07082009.txt represents the system date. This type of .txt gets FTP on a daily basis. My requirement is to rename the fd40568-07082009.txt to fd40568-07072009.txt... (2 Replies)
Discussion started by: rahulbahulekar
2 Replies

7. Shell Programming and Scripting

HowTo: reg expr doing grep "timestamp>$DesiredTime" logfile ?

I know I asked a similar question but I want to know if there is a regular expression existing that with a korn shell cmd, finds any timestamp data records in a file where it is greater then a timestamp in a shell variable ? something like : grep all records where it has a timestamp >... (5 Replies)
Discussion started by: Browser_ice
5 Replies

8. UNIX for Dummies Questions & Answers

sysdate -1 in unix

I need to automate the creation of a file. It needs to have the date of the previous day. In sqlplus we use sysdate -1 but I checked the man page for date and didn't find a similar command. This is what I use for creating a file for the current date: rciind`date '+%m%d%Y'`.txt What do I... (1 Reply)
Discussion started by: kskywr
1 Replies

9. UNIX for Dummies Questions & Answers

sysdate -p -f%d/%m/%Y

Dear I check script written in Unix commands and i face misunderstanding in date format. the format is ( sysdate -p -f%d/%m/%Y ). can you told me what is ( -p and -f ) means. and can you write sample for this. (1 Reply)
Discussion started by: abu_hassan
1 Replies

10. UNIX for Dummies Questions & Answers

How to get sysdate -1

Hi, How can i change date value to date value - 1 in unix ? I mean sysdate to sysdate -1. Can anyone throw some light on that ? cheers, gopskrish (2 Replies)
Discussion started by: gopskrish
2 Replies
Login or Register to Ask a Question