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 正则表达式笔记

    #!usr/bin/env python3 #-*- coding:utf-8 -*- #正则表达式 #在正则表达式中,如果直接给出字符,就是精确匹配.用\d可以匹配一个数字,\w可以匹配一个字母.数 ...

  2. 输入系统:epoll & inotify

    一.epoll 作用:检测一个或多个文件的可读.可写等属性变化: 代码示例: #include <sys/epoll.h> #include <stdio.h> #includ ...

  3. 2.17 C++类与const关键字

    参考: http://www.weixueyuan.net/view/6348.html 总结: const成员变量的初始化只有唯一的一条途径:参数初始化表. const成员函数可以使用类中的所有成员 ...

  4. do文件的编写(转)

    以前在使用ModelSim进行仿真的时候,一直是使用其GUI进行操作的,但是这样很繁琐也很费时.故希望学习其自动化仿真do文件,下面是学习的一些总结. 一.编写基本的do文件 下面按照实际仿真的步骤来 ...

  5. setcookie

    cookie 中值的部分在发送的时候会被自动用 urlencode 编码并在接收到的时候被自动解码并把值赋给与自己同名的 cookie 变量 首先声明,浏览的Cookie操作都是通过HTTP Head ...

  6. sql order by 结合case when then

    SELECT * FROM datav.a_current_per_entry_01 WHERE intime = (SELECT MAX(intime) FROM a_current_per_ent ...

  7. diary of laravel

    1.  修改数据库连接 初始化数据库:   首先: 修改 config- database.php 中的 数据库链接 其次:修改   .env 中数据库链接 创建表: php artisan migr ...

  8. 【Python】xml 解析

    1. XML:指可扩展标记语言,是一种标记语言,用于存储数据和传输数据,但没有像HTML那样具有预定义标签,需要程序猿自定义标签 2. XML的解析:读取XML数据结构中的某些信息,比如读取书的属性 ...

  9. 2.28 查看webdriver API

    2.28 查看webdriver API(带翻译) 前言    前面都是点点滴滴的介绍selenium的一些api使用方法,那么selenium的api到底有多少呢?本篇就教大家如何去查看seleni ...

  10. 2.11 alert\confirm\prompt

    2.11 alert\confirm\prompt 前言   不是所有的弹出框都叫alert,在使用alert方法前,先要识别出到底是不是alert.先认清楚alert长什么样子,下次碰到了,就可以用 ...