Cretae a new file with cmd
To create a new file using the Command Prompt (Cmd) in Windows, you can use the following command:
type nul > newfile.txt
This will create a new file called newfile.txt
in the current directory.
Here's how it works:
type
is a command that outputs the contents of a file to the screen.nul
is a special file that represents the null device, which means it doesn't actually exist. When you usetype
withnul
, it creates a new file and writes nothing to it.> newfile.txt
redirects the output of thetype
command to a new file callednewfile.txt
.
You can also use the echo
command to create a new file with some initial content:
echo. > newfile.txt
This will create a new file called newfile.txt
with a single newline character (\n
) as its contents.
Alternatively, you can use the touch
command (available in Windows 10 and later) to create a new file:
touch newfile.txt
This is similar to the type
command, but it's a more straightforward way to create a new file.