Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grep for date

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to grep a log file for todays date without the time etc
ie:: date +"%a %b %d"
so I want to grep for Fri Feb 08

having problems with this.tried assigning this to a variable
ie ::set datevar=`date +"%a %b %m"`and tried to grep for that variable but grep only reads the first part ie FRI and not the whole string as one.

Any hel pappreciated

 
Hi,
Try this.

#!/bin/sh
#
#
datevar=`date +"%a %b %d"`
grep "$datevar" whateveryourlogfile.is

Later!
DT
 
Not sure what shell your using but this worked for me in a ksh script:

#!/usr/bin/ksh
date_var=`date +"%a %b %d"`
grep "$date_var" *


hth


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top