In Linux, we can create an empty file using ‘touch‘ command. There’s no equivalent command for touch in Windows OS. However, we can still create zero byte files using the command
The syntax of fsutil command for creating a file is:
fsutil file createnew filename requiredSize
Below is the command you can run to create a empty text file.
fsutil file createnew filename 0
C:\>fsutil file createnew emptyfile.txt 0 File C:\emptyfile.txt is created C:\>dir emptyfile.txt 02/06/2012 10:50 PM 0 emptyfile.txt C:\>
The above command can be run from a batch file also. It works on all Windows editions: XP, Server 2003, Vista, Windows 7, Server 2008.
‘fsutil‘ command should be run from elevated administrator command prompt. Otherwise, you would get the below error message.
c:\>fsutil file createnew emptyfile.txt 0 The FSUTIL utility requires that you have administrative privileges.
Using echo command
In Linux, we can use echo command also to create empty text files. This command is available in Windows also.
But using ‘echo’ we can’t create empty files. See below.
c:\> echo > newfile.txt c:\> c:\>dir newfile.txt 02/06/2012 10:47 PM 13 newfile.txt c:\>
As you can see, it has created a file of size 13 bytes.