Skip to content

Instantly share code, notes, and snippets.

@ymek
Created October 31, 2012 19:01
Show Gist options
  • Select an option

  • Save ymek/3989130 to your computer and use it in GitHub Desktop.

Select an option

Save ymek/3989130 to your computer and use it in GitHub Desktop.
#!/bin/bash
filename='/tmp/newdata.json'
while read line; do
if [ -z "$(echo $line | grep -vP "^$" | grep -vP "^//")" ]; then
echo > /dev/null
else
query="db.foo_collection.insert($line)"
echo -e "$("mongo localhost/my_db_name --eval \"'$query'\"")\n\n"
fi
done < "$filename"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment