Wouldn't "cat $today" result with "cat: No such file or directory: 2019-01-08"? Did you mean echo instead of cat?
My real life use case for these dynamic variables would be more like "cat/vim/cp $log" to get today's log file which would expand to something like /somedir/logs/201901/09/product.log. Handy when you have a large matrix of products/environments.
Only in the case when no such file exists in the current directory :)
Re:Bash 5.0 released
by edoloughlin on Tuesday January 08, 2019 @08:46AM
(#18855434)
* "cat $today" is easier to type than "cat $(today)"*
Except you should really be in the habit of typing "cat ${today}" ;)
Re:Bash 5.0 released
by yjftsjthsd-h on Tuesday January 08, 2019 @09:16AM
(#18855610)
Except you should really be in the habit of typing `cat "${today}"` ;) Quote everything!
Why? The {} doesn't prevent glob expansion or field separation.
Re:Bash 5.0 released
by Vogtinator on Tuesday January 08, 2019 @02:55AM
(#18854030)
It's not obvious that just expanding a variable runs code though.
On the plus side, TIL the subshell syntax plays well with eval/expand shortcut (ctrl+alt+e).