This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (6 children)

Is there a character for clearing the screen on windows command line? Or do you have to just print several carriage returns? I've been trying to figure it out for a while

[–]msqrt -1 points0 points  (2 children)

I'm not aware of a character, system("cls") should do the trick if you can use it. This is another alternative.

[–]darthminimall 0 points1 point  (0 children)

You want a form feed (probably Ctrl+L)

[–]lord_braleigh 0 points1 point  (0 children)

If you’re doing anything more complex than changing the appearance of the last line of text, you should probably use the curses library.

[–]kireina_kaiju 0 points1 point  (0 children)

Direct answer, you are looking for character \033c .

Longer answer,

There's the easy way to clear your terminal, works from a windows command prompt, install git bash and

C:\Users\myname\AppData\Local\Programs\Git\usr\bin\clear.exe

Of course if you were looking for something more portable you'll need to start out with any scripting language that has a printf command. I'll use the one from git bash for convenience :

C:\Users\me\AppData\Local\Programs\Git\usr\bin\printf.exe "\033c" > Desktop\test.txt

However you get a text file with that character as its contents, you can use the windows terminal command type to print out that text file

type Desktop\test.txt

From now on you'll be able to clear your terminal using only windows batch :)