It is currently Tue, 17 May 2022 18:28:52 GMT



 
Author Message
 Building a FileName Variable
Hi,

I am quite new to Unix (Korn Shell) scripting, having learned mostly
from looking at existing scripts.

I am working on a ksh script in which I would like to assign some string
values (including a date stamp) to a variable that will be used as a
file name. Here is what I want to do:

myfilename='string1' + date "+%EY%m%d" + '.txt'

The variable myfilename would hopefully become: 'string120010424.txt',
but I am not getting this result - I am aware that the plus(+) sign is
not the proper concatenation character but can't seem to find the right
one. I have checked the ksh man pages and searched deja.com but have not
been able to figure this out.

Any hints would be appreciated!

Thanks,

Dave
(Please respond to newsgroup only)



 Sun, 12 Oct 2003 01:56:40 GMT   
 Building a FileName Variable
On Tue, 24 Apr 2001 11:56:40 -0600, David Ward

myfilename=string1`date "+%EY%m%d"`.txt

Lew Pitcher, Information Technology Consultant, Toronto Dominion Bank Financial Group
(Lew_Pitc...@td.com)

(Opinions expressed are my own, not my employer's.)



 Sun, 12 Oct 2003 02:04:16 GMT   
 Building a FileName Variable
In article <3ae5bf59.714398...@news21.on.aibn.com>,

Even simpler:

myfilename=`date +string1%EY%m%d.txt`

I'm not sure why people are always so reluctant to put literal text in
date's format parameter.  The only problem would be if string1 were a
variable, in which case you have to be careful in case its value contains a
'%' character.

--
Barry Margolin, bar...@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



 Sun, 12 Oct 2003 02:17:18 GMT   
 Building a FileName Variable
On Tue, 24 Apr 2001 18:17:18 GMT, Barry Margolin <bar...@genuity.net>
wrote:

Gosh! I never thought of that.

Thanks, Barry.

I learn something new every day ;-)

Lew Pitcher, Information Technology Consultant, Toronto Dominion Bank Financial Group
(Lew_Pitc...@td.com)

(Opinions expressed are my own, not my employer's.)



 Sun, 12 Oct 2003 02:57:13 GMT   
 Building a FileName Variable
Lew and Barry,

Thanks very much for your solutions! Both give me exactly what I was
looking for.

Regards,

Dave



 Mon, 13 Oct 2003 01:52:48 GMT   
 
   [ 5 post ] 

Similar Threads

1. egrep on a variable string and on a variable filename

2. Using Environmental Variable in Filename

3. substituting variables for filenames in c?

4. Substituting a variable containing a filename with spaces

5. Storing a list of filenames in a variable

6. Splitting up a filename into script variables

7. Portable way to build filenames from ansi date?

8. does makefile have a built in PWD variable ?

9. how to use variables to build pipes?


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software