How do I grep a Date correctly
I am still a novice at this stuff, but I have searched everywhere and I cant seem to get this working.
I am using a database program that I need to pull information from. The command I am using is the following.
search /project | grep "date -v -1m "+%Y-%m""
This returns no results, however if I break it down it doesnt make sense to me because,
date -v -1m "+%Y-%m""
will return the result of "2009-02"
If I run the command
search /project | grep "2009-02"
I get the results I expect (every file with a creation date or modification date of 2009-02
If I create a variable x=2009-02
then run the command
search /project | grep "$x"
this works and returns all the files created or modified in 2009-02
So why is it that if I set my variable as the date of the previous month using
lastmonth=" date -v -1m "+%Y-%m""
and then run the search with
search /project | grep "$lastmonth"
gives me no results?
Also, FYI, I tried running the whole command together
/search /project | grep " date -v -1m "+%Y-%m""
and still got no results.
Please help. I feel like I've been going in circles on this for 2 days now.
Thanks
-- Jason
|