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 2.4k times
2
Sean Hetzel
- 390
- 1
- 2
- 10
-
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
6
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
- 3,959
- 3
- 33
- 53
Sean Hetzel
- 390
- 1
- 2
- 10
-
-
9type nul > fileName.txt, This creates empty file and works on windows 10. – renukar Jul 19 '19 at 09:47
-
-
1
-
@itay_alon That actually puts the text 'nul' in the file, on Windows 7. – Brōtsyorfuzthrāx Aug 21 '21 at 11:33