TIMESTAMP

 
SOLVED
Go to solution
Unix or Linux?
Frequent Advisor

TIMESTAMP

Is there any function that will re-adjust a variables value. E.g. I have a variable such as:

TIMESTAMP=`/bin/date '+%d%m%Y %H:%M:%S'`

echo "Start time: $TIMESTAMP"

...... more code etc......

echo "Finish time: $TIMESTAMP"


I know that I can insert the line before the final one to achieve this . i.e.


TIMESTAMP=`/bin/date '+%d%m%Y %H:%M:%S'`

echo "Start time: $TIMESTAMP"

...... more code etc......
TIMESTAMP=`/bin/date '+%d%m%Y %H:%M:%S'`
echo "Finish time: $TIMESTAMP"


Any other options?
3 REPLIES 3
Ivan Ferreira
Honored Contributor
Solution

Re: TIMESTAMP

If you will be using the TIMESTAMP variable only once, then there is no need for the variable existence, just use:

/bin/date +"Start Time: %d%m%Y %H:%M:%S"
.
.
.
/bin/date +"Finish Time: %d%m%Y %H:%M:%S"
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
James R. Ferguson
Acclaimed Contributor

Re: TIMESTAMP

Hi:

Change the TIMESTAMP setting to look like:

# TIMESTAMP='echo `/bin/date "+%d%m%Y %H:%M:%S"`'

...adding the 'echo' and double quotes in lieu of single ones as noted. Then:

# echo "Finish time\c"; eval ${TIMESTAMP}

Regards!

...JRF...
Unix or Linux?
Frequent Advisor

Re: TIMESTAMP

Thanks