Question:
I’m trying to automate a script and I need to capture the abbreviated name of the previous month in a variable (e.g. in June, I need the variable to return May). I have the following script, but I’m having trouble assigning it to a variable:date --date="$(date +%Y-%m-1)-1 month" +%b
Running the above returns ‘May’
But
mo=date --date="$(date +%Y-%m-1)-1 month" +%b
throws this error: -ksh: -ksh: not found [No such file or directory]Thanks for any help.
Answer:
You need command substitution to capture the output of a command:If you have better answer, please add a comment about this, thank you!