Is it possible to get current time ( and possibly date ) without doing it via a subshell?
because if I'm not mistaken, this command do open a subshell?
d=$(date)
Is it possible to get current time ( and possibly date ) without doing it via a subshell?
because if I'm not mistaken, this command do open a subshell?
d=$(date)
With Bash≥4.2 you can use printf with the %(datefmt)T format:
printf '%(%c)T\n' -1
-1 means now.
See The Bash reference at the printf entry.
To put it in a variable (and hence not use a subshell):
printf -v d '%(%c)T' -1
echo "$d"