Parsing Date to a file name

Hi All

There is a file "apple_2008-08-15.log".

I have to use grep on this file to collect my test log. There are 45 such files. Is there a command that I can use to dynamically substitute the daily date as part of the file name? As of now Iam renaming the file to the new date and running my shell script. Please help me.

Also please let me know how to a create folder with the current date as its name dynamically.

for your first part - why not do a

for i in $(ls)
do
...
done

loop, and for your 2nd question, the following should set you on the right path:

#  date +%Y-%m-%d
2008-08-18

That's a Useless Use of ls right there.

for i in *
do
  ...
done

Hi All

Thanks for your replies...

But what Iam looking for is something like

cat apple_<command to substitute the current date>.log

:slight_smile:

ok - what I should have said was

for i in $(ls apple*.log)

bu I was being lazy :wink:

That's still a Useless Use of ls

for i in apple*.log

Hi All

Thanks for all your replies..

The following satisfied me with the output.

cat apple_`date +%Y-%m-%d`.log

Thanks...