How to put the output of a mongo query in a linux file?

Hi everybody

I’d like to run a mongo query and put the output of this query within a linux file.
For instance, I’d like to put the output in a file so-called /tmp/MongoQuery…How to do that please?

Many thanks for your suggestions
Regards
Richard

One way would be to use –query option of mongoexport for the query and –out to specify /tmp/MongoQuery.

See https://docs.mongodb.com/database-tools/mongoexport/