Date in destination filename

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
gregmsp
Posts: 1
Joined: Tue Oct 18, 2011 4:40 pm

Date in destination filename

Post by gregmsp »

I am trying to transfer a file with a date variable embedded in the destination filename. The variable is created with the statement IDATE="`date +%Y%m%d`"
When I attempt the transfer with the command put //DD:FILE1 file1_email_$IDATE.txt, the file is created on the destination server with the filename file1_email_20111017.txt, which is what I expect. However, if I attempt to transfer the file using the command put //DD:FILE1 file1_$IDATE_email.txt, a file is created on the destination server with the filename file1_.txt. This is not what I expect. Is there a command that will create a file named file1_20111017_email.txt?
coz
Posts: 392
Joined: Fri Jul 30, 2004 5:29 pm

Re: Date in destination filename

Post by coz »

Greg,

You'll need to wrap braces {} around your shell variable name:

Code: Select all

//DD:FILE1 file1_${IDATE}_email.txt
If you don't do this, the shell will match the longest possible name for the variable, even if it isn't defined. In your case, this would be "IDATE_email".

--Steve
Post Reply