Creating and running shell scripts

Command summary (discussed as follows):

  • mongo [<database>] --eval "command": Direct command execution
  • mongo <JavaScript>: Runs the shell script specified

There are two ways in which you can run a shell script using mongo; issuing a direct (single) command using the --eval flag, or by creating and running a shell script.

Get MongoDB 4 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.