grep a file by date

Hi,
How to grep a file by its date as filename. For example test_20111003114318.txt. I tried something like below

egrep -v "^$|[/]$" test_20111003114318.txt

But I don't want to hard code the name as above , because I need to go and change it everyday..
new_perl_userAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

themrrobertCommented:
you could make a bash script which takes the date as an argument and then implements it into the command?
0
themrrobertCommented:
Save as dgrep and run ./dgrep 20111003114318 to find the file. I believe the script is correct, i will test it when i get my linux machine online
#! /bin/bash
# run egrep on date
egrep -v "^$|[/]$" test_$1.txt

Open in new window

0
new_perl_userAuthor Commented:
can I implement in the above command.

something like  egrep -v "^$|[/]$" test_$date.txt
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

themrrobertCommented:
My solutions is to create a new file, dgrep in your current working directory. Copy/paste my code into this file, and then run chmod +x dgrep

Then you can run ./dgrep 2020204083 and it will run the search.

$1 is the reference to the first command line argument passed to the script, the name is not arbitrary
0
new_perl_userAuthor Commented:
what if I automate the process rather than running it from command line
0
PapertripCommented:
Do you need to grep filenames with specific timestamps or can you glob it?  If you need specific dates, how do you determine which dates need to be passed to the script?
0
new_perl_userAuthor Commented:
it always will  be the sysdate. No worries about time. If it will able to pick up file by sysdate then it should be fine.
0
PapertripCommented:
egrep -v "^$|[/]$" test_`date +%Y%m%d%H%M%S`.txt

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.