如何禁用副本集监视器输出

yuy*_*u33 9 mongodb

我有一个bash脚本,它试图通过连接到副本集来监视集合中的文档数.

COUNT=`/bin/mongo --quiet --host $REPLICA_SET policy -u myuser -p mypwd --eval 'db.myColl.count()'`
Run Code Online (Sandbox Code Playgroud)

我期待只有一个数字作为输出,但我得到:

Mon Apr 27 13:33:57.716 starting new replica set monitor for replica set xx wit                                                                             h seed of xxx 
Mon Apr 27 13:33:57.719 succes                                                                             sfully connected to seed xx for replica set xx
Mon Apr 27 13:33:57.719 changing hosts to ...  

...

Mon Apr 27 13:33:57.736 [ReplicaSetMonitorWatcher] starting 3043
Run Code Online (Sandbox Code Playgroud)

谁能告诉我如何禁用这一堆输出?谢谢.

cof*_*ine 1

我不知道如何禁用它。作为解决方法,您可以a)tail -1您的输出,或b)输出一个在您的输出之前可能是唯一的标记,然后grep输出(例如在 js: 中print("__myAwesomeOutput__=" + x + ";"))。