I have the below code snippet :
#!/bin/bash
time="date +\"%Y-%m-%d %T,%3N\""
eval echo "`\$time` check"
Actually this is a part of a much larger code . I want to compute the value of time as per the above command on the fly every time the script is run and print the output.
When I run the code this is the below error I get :
date: extra operand ‘%T,%3N"’ Try 'date --help' for more information. check
However when I try to run the command from the command line window it runs fine. The problem is the date has to be in the same format only in the output.
$ date +"%Y-%m-%d %T,%3N"
2017-01-13 11:54:36,604
Please guide me out what should be done in this case.
Thanks in advance for any help
'\''s and the extra quotes.time=$(date +"%Y-%m-%d %T,%3N")eval, without knowing its consequences.