General discussion

Locked

shell script date

By adrian_buzea ·
How can I use the current (system)date as a variable in a NT shell script?

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

shell script date

by TimTheToolMan In reply to shell script date

Hi,

There is no direct access to the date from an NT shell script, but you can access it by doing something like...

date /t > temp.txt
for /F "tokens=2*" %i in (temp.txt) do echo %i

will set the environment variable %i to the date.
Here is an example...

E:\Documents and Settings\Tim Medhurst>date /t > temp.txt

E:\Documents and Settings\Tim Medhurst>for /F "tokens=2*" %i in (temp.txt) do echo %i

E:\Documents and Settings\Tim Medhurst>echo 01/04/2002
01/04/2002

E:\Documents and Settings\Tim Medhurst>

Cheers,
Tim.

Back to Windows Forum
1 total post (Page 1 of 1)  

Related Discussions

Operating Systems Forums