LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Setting environment variable to current date/time (http://www.linuxquestions.org/questions/programming-9/setting-environment-variable-to-current-date-time-221502/)

nafan 08-23-2004 07:04 PM

Setting environment variable to current date/time
 
I've been trying to find out if there is a way of setting an environment variable ($DATETIME) with the current date & time , but I've had no luck. Any pointers on how to do it would be greatfully received. It's my intention to use the variable in a bash shell script in a command similar to...
Code:

/usr/bin/make -s RELEASE="0.3.3-SVN $DATETIME"
Thanks in advance.

arvind_sv 08-23-2004 09:04 PM

Code:

DATETIME="`date +%d%m%y%H%M%S`"
/usr/bin/make -s RELEASE="0.3.3-SVN $DATETIME

or

Code:

DATETIME=$(date +%d%m%y%H%M%S)
or even:

Code:

/usr/bin/make -s RELEASE="0.3.3-SVN $(date +%d%m%y%H%M%S)
Please read the Bash (or some other shell's) manual, or the "Advanced Bash Scripting Howto" at http://tldp.org/HOWTO/Adv-Bash-Scr-HOWTO/index.html

Arvind


All times are GMT -5. The time now is 11:15 AM.