When I run the command date +%s directly on unix terminal, it correctly executes and gives number of seconds since 1970.
However, when the same command is in a script file, say temp.sh as below:
business_dt=date +%s
echo $business_dt
On executing above script, it throws error as below:
-ksh: +%s: not found [No such file or directory]
How to resolve this issue?
You need to use command substitution to assign the output of a command to a variable. The syntax is
var=$(command). So, try changing your script to: