Anusha Bayya
Anusha Bayya

Reputation: 103

Clear Contents of File from cmd

I have a file named testFile.js. js file contains some javascript code. I wanted to know how do I delete the file content alone from command Prompt (Windows).What is the command I should use?

Thanks :)

Upvotes: 1

Views: 1973

Answers (3)

Bob
Bob

Reputation: 153

This will clear the file completely:

TYPE NUL > testFile.js

Upvotes: 2

Difster
Difster

Reputation: 3270

Instead of my previous answer try this.

del testFile.js
COPY CON testFile.js

You will get just a blinking cursor. Press F6 and then enter. Your zero byte file will be created.

Upvotes: 1

Difster
Difster

Reputation: 3270

Try this at the command prompt assuming you're already in the directory containing the file.

echo.> testFile.js

Upvotes: 2

Related Questions