Quote:
Originally Posted by andycol500
Hi Guys
Any ideas how I can script it to find todays date and then pull all lines out of /var/log/secure with todays date then > into a file.
cat /var/log/secure | grep "date +"%b %d""
Doesnt seem to work
Any ideas
|
A quick and dirty hack would be something like this:
Code:
MONTH=$(date +%b)
DAY=$(date +%d)
DAY=${DAY#0}
grep "${MONTH} ${DAY}" /var/log/secure
since the log file format is like the following:
Code:
Jul 1 10:26:14
Jul 2 10:26:13
hope that helps
EDIT: as a side note, you have a useless use of `cat` there. `grep` is able to handle a file as an argument so you do not need to `cat`-it and then grep through the lines returned by `cat`.