Is it possible to store mongo output into a variable in shell script, below is the example query which prints decimal date
ex: 1489442900000
maxdate =$( echo mongo getmaxdate.js --quiet)
Any help is highly appreciated.
Thanks, Ashwin.
There should be no space between the variable name and the command during the assignment.
variable_name=$(command1 |command2 .....)
In your case:
maxdate=$( mongo getmaxdate.js --quiet)
Make sure to preserve the formatting of the output. if echo'ed Without double quote the whole content will show up in one line.
echo "$maxdate"
mongo getmaxdate.js --quiet)" , this is working for me.