Use result from mongodb in shell script
The superfluous output is the result of your assignment of a='b'
, which displays the result of the assignment in this context.
If you add the var
keyword for variable assignment, you shouldn't have any extra output (and can still use the variable a
in your script):
$ mongo --quiet --eval "var a='b'" mongoscript.jsfoo
You can see the same behaviour in the mongo
shell:
> a='b'b> var a='b'>