help with date parameter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with date parameter
# 1  
Old 04-23-2012
help with date parameter

I have a file with timestamp in the file name

Code:
FILE=DETAIL_20120419141952_CODE.txt

I am using the below expression to derive the file name

Code:
FILE=DETAIL_$(date +'%Y%m%d')*_CODE.txt

echo gives me correct filename

but when I call it as a paramter to another script its being taken as.

Code:
DETAILS_20120423*_CODE.txt

I am calling it as
Code:
abc.ksh $FILE

can somebody let me know how I should make sure this paramteter picks the correct file. There will always be 1 file with that name on any day

Moderator's Comments:
Mod Comment Link: How to use [code] tags

Last edited by Scrutinizer; 04-23-2012 at 05:33 PM.. Reason: code tags
# 2  
Old 04-23-2012
Why exactly do you need a '*' in the file name?
Would the following work?
Code:
FILE="DETAIL_$(date +'%Y%m%d')_CODE.txt"
abc.ksh "${FILE}"

# 3  
Old 04-23-2012
I need the parameter to resolve to the full file name.

the * resolves to hours minutes in the file name

I don't want a * in the run time.

I want the FILE value to resolve to the full file name
# 4  
Old 04-23-2012
This is because the * does not get expanded during variable assignment. It does get expanded when used as a parameter, for echo, printf or ls for example.

Last edited by Scrutinizer; 04-23-2012 at 06:27 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to replace a parameter(variable) date value inside a text files daily with current date?

Hello All, we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies

2. UNIX for Beginners Questions & Answers

Add parameter in UNIX from date

Hello All, I am printing name of the files from the server(XXCU_DATA_TOP/AP/in/123). Now I want to add From Date Parameter and retrieve files from server from a specific date(From Date Parameter) on the server path. Ex. Parameter: 01-Oct-2017 so the file name should be print from 01-Oct-2017. ... (16 Replies)
Discussion started by: Nileshta
16 Replies

3. Shell Programming and Scripting

Pass date (YYYY-MM-DD) as parameter and get Day

Hi, I have a requirement where I have to pass Date to a script and get the day from it. Ex If parameter is 2015-09-29 The output should be Tuesday. Can you please tell me how to get that? (6 Replies)
Discussion started by: ashwin3086
6 Replies

4. Shell Programming and Scripting

Last date of month based on parameter

Hi All, How do i get the last date of a month in Unix based on a parameter value. My requirement is if i pass 03/05/2014 as parameter, then i shud get the output/return value as 2/28/2014 If i pass 03/31/2014 as parameter, the output/return value should be 03/31/2014 itself. Also,... (2 Replies)
Discussion started by: galaxy_rocky
2 Replies

5. Shell Programming and Scripting

Parameter file with changing date

Hi, I have a trigger file which looks like this abcdefgh_YYYYMMDD.trg The YYYYMMDD is the year, month and the date. So for example today the trigger file would be abcdefgh_20130703.trg similarly tomorrow it would be abcdefgh_20130704.trg I need to write a script to check if the trigger file... (2 Replies)
Discussion started by: halfafringe
2 Replies

6. UNIX and Linux Applications

Passing date parameter on Kshell command line

I need to execute a .ksh from command line. The ksh calls a control file and has 3 parameters. First parameter is a csv file, second the target table in oracle and third parameter is a date parameter. I am attempting the below from the ksh command line {code} => testfile.ksh filname.csv... (1 Reply)
Discussion started by: kobe24
1 Replies

7. Shell Programming and Scripting

Shell script with date parameter

Hi All I have a shell script which calls all the Teradata Utiltyes . There is a sudden change in the requirment . What i'm asked to do is pass on the DATE to the shell script which should take the date automatically and run the utilityes. i.e. the date should not be passed on... (5 Replies)
Discussion started by: vinayrao
5 Replies

8. Shell Programming and Scripting

passing date parameter in cronjob

Hi All, I have a crontab entry for every 5 min running. 5 * * * * /tmp/scripts/ksh/CsVues_H.sh `date +%Y%m%d_%H` >> /tmp/scripts/ksh/Cronresult.log and I am passing the date parameter. ( `date +%Y%m%d_%H` ) But the parameter values which i am expecting inside the script is... (6 Replies)
Discussion started by: scorpio
6 Replies

9. Solaris

passing an input parameter like date thru jcl using BPXBATCH utility

Hi.... i need to pass the dates (from - to) as the input parameters thru jcl invoking BPXBATCH utility. I know that PARM will do the above functionality. But how the above dates passed through jcl will be linked in the java-db2 program to be used in sql queries in order to generate the report... (0 Replies)
Discussion started by: Sujatha Gowda
0 Replies

10. Shell Programming and Scripting

Passing Date as parameter with sh script

Hi I need to pass a date argument with my shell script. Can any one send me code for the same. eg For 15th Aug 2006. Iwant to pass parameter like this ./startenv.sh 08/15/2006. Everyday date argument must change. Will the below code work ? ./startenv.sh date '+%m/%d/%y' THanks... (1 Reply)
Discussion started by: pankajkrmishra
1 Replies
Login or Register to Ask a Question