bash command not found when setting a variable

You define variables with var=string or var=$(command).

So you have to remove the leading $ and any other signs around =:

tag_name="proddeploy-$(date +"%Y%m%d_%H%M")"

deploy_date=$(date +"%Y%m%d_%H%M")
            ^^                   ^

From Command substitution:

The second form `COMMAND` is more or less obsolete for Bash, since it
has some trouble with nesting (“inner” backticks need to be escaped)
and escaping characters. Use $(COMMAND), it’s also POSIX!

Also, $() allows you to nest, which may be handy.

Leave a Comment