如何清除 MongoDB 中的控制台

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13327218/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 12:55:52  来源:igfitidea点击:

How to clear console in MongoDB

mongodbmongo-shell

提问by Salvador Dali

While using Mongodb console or shell sometimes my screen is cluttered with a lot of previous output which I do not need. So, is there a function to clear console in MongoDB?

在使用 Mongodb 控制台或 shell 时,有时我的屏幕上堆满了许多我不需要的先前输出。那么,MongoDB 中是否有清除控制台的功能?

Something like an analog of clear in MatLab.

类似于 MatLab 中 clear 的模拟。

I have tried clc, clearbut with no success.

我试过clcclear但没有成功。

回答by Salvador Dali

Judging by Jirathey have done it: You need to write clsin the shell.

Jira来看,他们已经做到了:您需要cls在 shell 中进行编写。

You can also use a hotkey: CTRL+ L.

您还可以使用热键:CTRL+ L

In macOS: Command+ K.

在 macOS 中:Command+ K.

Check more hotkeys for the shell here.

此处检查外壳的更多热键。

回答by Stennie

If you are using MongoDB 2.0 or higher, the mongoshell supports both:

如果您使用的是 MongoDB 2.0 或更高版本,mongoshell 支持两者:

  • clscommand
  • Ctrl+l(clear screen)
  • cls命令
  • Ctrl+l(清屏)

Note that both of these clear the screen and put the cursor at the top .. but you can still scrollback to see previous history.

请注意,这两者都会清除屏幕并将光标放在顶部……但您仍然可以回滚以查看以前的历史记录。

In OS X Terminal.app you can also do:

在 OS X Terminal.app 中,您还可以执行以下操作:

  • Command+K(clear scrollback)
  • Command+K(清除回滚)

Clearing the screen and/or scrollback buffer are independent of the history, so you can still cursor up/down to run previous commands.

清除屏幕和/或回滚缓冲区与历史记录无关,因此您仍然可以向上/向下光标以运行以前的命令。