The --eval command line option gets awkward when the JavaScript is non-
trivial. But you can execute a longer script stored in a file. The
file must be pure JavaScript, so shell commands like "use dbname"
don't work, so you must specify the database to use in the command
line args. For example:
> mongo --host hostname --port portnumber dbname script.js
or
> mongo hostname:portnumber/dbname script.js
will connect to the server at hostname:portnumber and execute the
script stored in the file "script.js".
When running the script it doesn't echo the results of each line to
standard output the way the shell does when you run it in interactive
mode, so you can debug the script in interactive mode first.
As far as the remove statement itself goes, wouldn't it just be
something like:
> var cutoff = ISODate("2011-05-20")
> db.test.remove({updated_at : {$lt : cutoff}})