AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  Creating a filelist

    Posted Thu September 22, 2011 04:34 PM

    Originally posted by: mahekr2000


    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!
    #AIX-Forum


  • 2.  Re: Creating a filelist

    Posted Fri September 23, 2011 06:28 AM

    Originally posted by: SystemAdmin


    You can use date +"%Y%m%d" to get current date
    1. date +"%Y%m%d"
    20110923

    This is the simpe script.

    #!/usr/bin/sh
    curdate=`date +"%Y%m%d"`
    for i in `ls | grep $curdate`
    do echo $i
    cp $i `echo $i | cut -d"_" -f1`.txt
    done

    If there is now file, you ETL job will read xyz.txt from the last run of this script.
    #AIX-Forum