30/08/2014

[DOS] touch equivalent command to create a file

How do you create a file from DOS?

Usually

some_command >> filename

works but what if you just need to create an empty file? Well there's no single command like touch you can use, but a simple way to achieving the same result is by combining type and the output redirection.

type, will show you the input file contents. type nul will return successfully without showing any output. Now it's just a matter of adding redirection:

type nul >> filename

and you'll have created and empty file.

No comments:

Post a Comment

With great power comes great responsibility.

Da grandi poteri derivano grandi responsabilità.