use shell command

method one:

#!/bin/bash

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

shell excute mongo query command的更多相关文章

  1. mongo实践-透过js shell操作mongo

    mongo实践-通过js shell操作mongo 保存命令: j={name:"wangjingjing",age:15} db.user.save(j); 查询命令: var ...

  2. excute和query

    query(update goods set is_delete=1 where goods_id=13)总是出错??为什么, excute(update goods set is_delete=1 ...

  3. Shell脚本出现$'\r': command not found

    Centos7下执行shell脚本报错如下 [root@ip---- ~]# sh install_zabbix_agent.sh install_zabbix_agent.: $'\r': comm ...

  4. jenkins构建执行shell 所有命令出现command not found

    出现的问题: + rsync -avzP /mnt/workspace/df-admin/ root@192.168.0.153:/home/deploy/deep_fashion_targets/w ...

  5. Linux Shell 错误: $'\r': command not found错误解决

    在Linux下执行程序最省事的方式就是将系统的执行流程封装成一个shell脚本,上传到linux环境中后就可以直接执行了,但是今天在具体实施的时候出现了错误 $'\r': command not fo ...

  6. 执行shell脚本出错'\r': command not found

    在linux中执行脚本时出错 $'\r': command not found 错误原因是在脚本中有空行,如果脚本是在Windows下进行编辑之后上传到linux上去执行的话,就会出现这个问题. 因为 ...

  7. [Jenkins] Creating Application builds

    After installing the jenkins, we start creating new job. 1. Give job names (your project name): 2. G ...

  8. MongoDB Shell (mongo)

    https://docs.mongodb.com/getting-started/shell/client/ The mongo shell is an interactive JavaScript ...

  9. MongoDB - The mongo Shell, Write Scripts for the mongo Shell

    You can write scripts for the mongo shell in JavaScript that manipulate data in MongoDB or perform a ...

随机推荐

  1. python 定义class时的内置方法

    __contains__():对类实例使用in ,not in操作时调用 class A(object): def __init__(self,num): self.num=num def __con ...

  2. python socket 网络编程selector用法 (实用)

    Server端: import socketimport selectors class Server(object):def init(self,sel,sock):self.sel = selse ...

  3. springmvc添加定时任务

    springmvc.xml文件中添加如下配置 <bean id="ClearTempRoomLogTask" class="com.test.listener.St ...

  4. 理解K系列与ultra-scale的区别

    总结:   K系列FPGA与KU系列FPGA的主要区别,体现在: (1)工艺制程不一样,K-28nm,KU-20nm:   (2)Ultra-Scale采用SSI:大容量K系列也采用SSI,SSI为了 ...

  5. system的共享内存实例

    system的共享内存指的是内核指定一块内存区域映射到虚拟地址空间供进程通信使用的机制 1\创建或打开共享内存块函数原型int shmget(key_t key, size_t size, int s ...

  6. Docker(2):快速入门及常用命令

    什么是Docker? Docker 是世界领先的软件容器平台.开发人员利用 Docker 可以消除协作编码时“在我的机器上可正常工作”的问题.运维人员利用 Docker 可以在隔离容器中并行运行和管理 ...

  7. rancher中使用ingress-lbs做负载均衡

    rancher 相关资料 http://rancher.com/docs/rancher/v1.6/zh/kubernetes/ingress/ lvs, haproxy, nginx负载均衡器比较 ...

  8. Python实现登陆的功能

    import datetimetoday=datetime.datetime.today()# 获取当前时间for i in range(3): username=input("请输入用户名 ...

  9. [转] ajax方法

    1.url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. 2.type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如 ...

  10. ios中字典转模型的创建以及简单用法

    // appModel.h // Created by zzqqrr on 17/8/19. // #import <Foundation/Foundation.h> @interface ...