Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
57 user(s) are online (31 user(s) are browsing Forums)

Members: 1
Guests: 56

rwo, more...

Headlines

 
  Register To Post  

Add date+time to filename
Just popping in
Just popping in


See User information
Is there a way to add the date+time to a filename when redirecting output? This is to be done in a Shell directly or a script.

MyProgram >T:Output_[date+time].txt

So each run doesn't overwrite the previous output file.

Go to top
Re: Add date+time to filename
Just can't stay away
Just can't stay away


See User information
What I usually do is set up a Shell variable with the date part of the filename, using something like "set dt = `date {your format codes here]`" (note the backticks).

Then you can use $dt as part of your filename - or, if you refer to it lots of times, set up another variable like "set fn = T:Output_$dt.txt" and then just use $fn when you need the filename.

Note: Untested, away from my Amigas right now.

Best regards,

Niels


Go to top
Re: Add date+time to filename
Just can't stay away
Just can't stay away


See User information
@mritter0
Maybe some variation of this:

echo testing >ram:testfile`date LFORMAT %H%M%S`

Note that the hash marks enclosing the date command are not single quotes; they are the character below the Esc key on a standard keyboard (I.E. the key with ~ and `).

Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450

Go to top
Re: Add date+time to filename
Quite a regular
Quite a regular


See User information
@mritter0

if it's not strictly the date you are after but the overwriting of the previous file from a script, maybe adding the process number to the file name is an option?

.Key test
.Bra {
.
Ket }

echo 
"hello Amigans World" >T:nameoffile{$$}



Go to top
Re: Add date+time to filename
Just popping in
Just popping in


See User information
Sweet. Worked great. Thanks

Workbench Explorer - A better way to browse drawers
Go to top
Re: Add date+time to filename
Just popping in
Just popping in


See User information
@mritter0

In case you need a single file containing the cumulative output data of previous execution/run , you may use: MyProgram >>T:Output.txt

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project