Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I clear the terminal in Ruby?

Tags:

ruby

I would like to know to how to do in Ruby what I can do with system("clear") in C. I wrote a program like

puts "amit" system("clear") 

I want the console to be cleared after executing this commnad, but it is not working.

like image 720
Milan Avatar asked Jul 03 '10 06:07

Milan


People also ask

How do I completely clear terminal?

A common way to do that is to use the `clear` command, or its keyboard shortcut CTRL+L.

How do I clear the terminal in Julia?

To clear Julia REPL, press Ctrl + L .

How do you delete a terminal in rails?

Clearing the Console To get a clean slate in your console, use Command + K on the Mac. You can also use Ctrl + L to clear the screen, which works on both Mac and Linux.

How do I clear the terminal when my server is running?

If you are using the default unity terminal, you can go to Terminal > Reset and clear. then you can view it using a text editor. That would let you scroll the file manually.


1 Answers

If you want something that is vaguely portable you can try:

system "clear" || system "cls" 

which will try both clear and cls

like image 51
jbr Avatar answered Oct 14 '22 12:10

jbr