In Mac OS a new file can be created from the terminal by using the touch
command. For example: $ touch hello_world.rb
.
Is there a way to create a new file of any type in cmd for Windows?
Asked
Active
Viewed 3.8k times
1

Sean Hetzel
- 448
- 1
- 3
- 13
-
2Have you tried to research?https://stackoverflow.com/questions/1702762/how-to-create-an-empty-file-at-the-command-line-in-windows – Kien Pham Apr 09 '19 at 03:08
-
Yeah I though that was only for .txt but I was mistaken. – Sean Hetzel Apr 09 '19 at 03:16
-
Well, an empty file is an empty file, there is no empty binary or text file since there is no data at all... – aschipfl Apr 09 '19 at 17:14
1 Answers
10
To make a file with some text, do
echo some_text > hello_world.rb
Or, as seen in the comments,
type nul > hello_world.rb
(Note that you actually type type
.)

Brōtsyorfuzthrāx
- 4,387
- 4
- 34
- 56

Sean Hetzel
- 448
- 1
- 3
- 13
-
1
-
9type nul > fileName.txt, This creates empty file and works on windows 10. – Renuka Jul 19 '19 at 09:47
-
-
2
-
@itay_alon That actually puts the text 'nul' in the file, on Windows 7. – Brōtsyorfuzthrāx Aug 21 '21 at 11:33