Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to call a file dynamically in shell script

Status
Not open for further replies.

navink123

Programmer
Sep 2, 2003
21
US
I have a job that needs to run daily. I need to write a shell script which will pick up a input file that is generated daily. The generated file is going to have the jobname with sysdate and some more characters appended to it. In this, jobname is going to remain same, the syadate will change daily and the last few characters will be generated daily automatically.

e.g. the name of the file will be :
on 26 th - abc20030826123
on 27 th - abc20030827234
on 28 th - abc20030828568

How can I call this file in the script.

Thanks,
Navin
 
navink123
Let's assume that your input files that are generated daily (eg. abc20030826123) are stored in a directory called /dailydata.

If your shell script needs to refer to a file generated in /dailydata on that day, then use the following in your shell script :

============================

today_date=`date '+%Y%m%d'`
myfile=`ls *${today_date}*`

============================

$myfile will give you the relevant filename.

Hope this helps ya.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top