shell excute mongo query command

use shell command 

method one:

#!/bin/bash

if [ $# -ne 1 ]
then
    echo 'Please input cid'
    exit
fi
HOST=192.168.1.1:27017
 
mongo ${HOST}/new_db << EOF
db.camp.findOne({"cId":$1});
EOF

method two:

 

echo"db.mycollection.findOne()" | mongo myDbName
echo"show collections" | mongo myDbName

 

refer:http://ask.helplib.com/281277

refer: http://www.epubit.com.cn/book/onlinechapter/27994

posted on 2017-06-06 15:53  iokde.com  阅读(203)  评论(0编辑  收藏  举报

导航