I am doing a simple script. I have to update the stored date value. For example
ss=date
;
sleep 5;
echo $ss;
It is showing old date. How to update the date after 5 seconds
I am doing a simple script. I have to update the stored date value. For example
ss=date
;
sleep 5;
echo $ss;
It is showing old date. How to update the date after 5 seconds
to update a variable it must be re assing: $(..)
is a command substitution it is expanded to output of specified command.
ss=$(date)
...
ss=$(date)
SECONDS
is a special variable which contains the number of seconds since bash process is running, to have a value changed every 5 seconds, following can be used.
echo $((SECONDS/5))