bash substring of command instead of variable? bash substring of command instead of variable? shell shell

bash substring of command instead of variable?


No, BASH syntax doesn't allow any kind of nesting. You can do so using external utilities like cut:

date | cut -c 1-10

Wed Jun 13


To replace date:

$ dateWed Jun 13 14:57:38 EEST 2018

you can use printf:

$ printf "%(%a %b %d%n)T"Wed Jun 13

man strftime for more format modifiers.


If you want the output Wed Jun 13 for today's date (which this is), then

$ date +'%a %b %e'Wed Jun 13

See the manual for date and/or for strftime on your system.