I had a strange problem when I tried to write scritp bash to copy some data from one database to another.
To make everything simple, I will talk about this in the following example:
Let's say we have a file that contains the mongo paste commands that need to be executed in mongo client. With Bashit will be:
cat file.json | mongo --verbose --host $HOST
This works fine until we use qoutes in the contents of the entries.
For example:
use somedb;
db["collection"].insert({ "field": "test" })
db["collection"].insert({ "field": "test \" test" })
db["collection"].insert({ "field": "test \\" test" }) "
db["collection"].insert({ "field": "\"test\"" })
, mongo ( MongoDB shell verions: 2.2.4)?
, script ?
, . Mongo ( --verbose), .