Creating a filelist

I need a script that will read a filename and verify that its today's file and rename it to a standard name so that my ETL job can read it on a daily basis. If there is no file for a day, I am thinking I will just read the one before to prevent my job from failing. Another option might be a filelist and I have the option of doing an indirect read as well (If there is a better way to do this please suggest).

The filename does have the date appended to it.

So, for example the name of the file for today will be something like:

xyz_20110922.txt

I need to take this and convert it as xyz.txt

Thank you in advance!

Try this...

ls * | awk -v date=`date +%G%m%e` '{if($0~date){file=$0;gsub("_"date,"");system("mv "file" "$0)}}'

--ahamed

---------- Post updated at 02:10 PM ---------- Previous update was at 02:08 PM ----------

or you can echo the file name and pipe it to awk

echo $file_name | awk ...

--ahamed