Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Technowise/90997242fa874a38e3b347e0fcbc3f6e to your computer and use it in GitHub Desktop.
Save Technowise/90997242fa874a38e3b347e0fcbc3f6e to your computer and use it in GitHub Desktop.
Shell script to import all MongoDB json files in current folder to remote database
ls -1 *.json | sed 's/.json$//' | while read col; do
mongoimport --host sample-mongodb-host.com --username john --password sample-password --db sample-db --collection $col --file $col.json
echo $cmd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment