I am trying to set an alias to show value of specific date command. When I set the alias, I get correct value, but also get "command not found..." Is there a way to set this without the error?
Summary:
I am trying to get last day of previous month for the current day. Todays date is: 20210221
I am using the following command to get the date I want:
date -d "$(date +%Y-%m-01) -1 day" +%Y%m%d 20210131
Results:
I set alias for this in .bashrc
[root@centos_8_1 ~]# alias | grep date alias test_date='$(date -d "$(date +%Y-%m-01) -1 day" +%Y%m%d)'
When I try to call, I get the correct value, but also get "command not found...
[root@centos_8_1 ~]# test_date bash: 20210131: command not found...
Questions:
Am I missing something with syntax?
How can I set an alias for this date?
What is the command that is not found?
First time poster, thanks for help.