83

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?

Something like an analog of clear in MatLab.

I have tried clc, clear but with no success.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98

2 Answers2

153

Judging by Jira they have done it: You need to write cls in the shell.

You can also use a hotkey: CTRL + L.

In macOS: Command + K.

Check more hotkeys for the shell here.

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
70

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

  • cls command
  • Ctrl+l (clear screen)

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:

  • Command+K (clear scrollback)

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

Stennie
  • 63,885
  • 14
  • 149
  • 175
  • The `mongo` shell also supports other [Keyboard Editing Shortcuts](http://docs.mongodb.org/manual/reference/mongo-shell/#keyboard-shortcuts) similar to those found in Emacs or the `bash` shell. – Stennie Jul 21 '13 at 12:43