I'm trying to use mongoimport to import multiple collections. I do that in a .sh file "seed.sh" which contains the following :
mongoimport --db blog --collection users --file ./db/users.json --jsonArray
mongoimport --db blog --collection articles --file ./db/articles.json --jsonArray
I use makefile in cygwin64 terminal. The first import always fails. The second always succeeds. This holds true if I change the order of the collection that is being imported. I receive the error "Error parsing command line: unknown option jsonArray". What is the problem here?
The problem is that your seed.sh file currently has CRLF line ending. Convert to LF line ending for seed.sh to work properly.
The problem is because of CR LF and LF characters line ending. Windows uses CR LF while Unix uses LF.
Now changing those two lines of yours to mongoimport --db blog --collection users --file ./db/users.json --jsonArray && mongoimport --db blog --collection articles --file ./db/articles.json --jsonArray will probably solve your problem.
for more information about line endings please refer to this stackoverflow post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With