3

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?

user3619165
  • 380
  • 1
  • 2
  • 13

2 Answers2

2

The problem is that your seed.sh file currently has CRLF line ending. Convert to LF line ending for seed.sh to work properly.

qminhdo
  • 86
  • 6
1

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.

MajidJafari
  • 1,076
  • 11
  • 15