How to Create Empty File Linux or Windows using a command prompt. A file can be created using the command [touch] in Linux. In Windows OS, touch does not have an equivalent command. The command fsutil
still allows us to create zero-byte files.
When creating a file, fsutil
uses the following syntax:
fsutil file createnew filename requiredSize
You can run the command below in order to create an empty text file that does not contain any data.
fsutil file createnew filename 0
Sample:
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:\>
A batch file can also run the above command. Worked on Windows 7, Windows 8, Windows 10, and Windows 2008 editions of Windows.
From a command prompt that has elevated administrator rights, run “fsutil”. You will otherwise receive the following error.
c:\>fsutil file createnew emptyfile.txt 0 The FSUTIL utility requires that you have administrative privileges.
Commands for echo:
You can create empty text files in Linux using the echo command. Windows also offer this command. When using “echo”, however, no empty files can be created. Below is an example.
c:\> echo > newfile.txt c:\> c:\>dir newfile.txt 02/06/2012 10:47 PM 13 newfile.txt c:\>
The file created has a size of 13 bytes as you can see in the image below.
You may also like: Findstr Command Examples & Regular Expressions