how to create a file in terminal windows code example

Example 1: make new file windows cmd

type nul > README.txt

Example 2: how to open a file using terminal

open ~/Desktop/filename.txt

Example 3: create a file cmd

type NUL > EmptyFile.txt
# also
echo. 2>EmptyFile.txt
copy nul file.txt > nul # also in qid's answer below
REM. > empty.file
fsutil file createnew file.cmd 0 # to create a file on a mapped drive

Example 4: terminal command to create new file

touch filename.txt

Example 5: create file and write to it cmd

echo some-text  > filename.txt

Example 6: cmd make new file

$null > filename (including the $)

Tags:

Misc Example