Systems Engineering and RDBMS

Creating an empty file in Unix and Windows

Posted by decipherinfosys on February 15, 2009

Recently at a client site, we came across a situation where we had to create empty files with a specific size on Windows.  We had to do this for R&D purposes in order to be able to mimic ASM in Windows environment without actually having different disks.

Windows has a utility called fsutil.exe. This is a command line utility. Mainly it is used for maintaining file and disk properties and is an advance level utility. But one of its fine usages is to create the empty file of a specific size. Following is the command to create an empty file.

C:\>fsutil file createnew c:\ttt.txt 2048
File c:\ttt.txt is created

C:\>dir ttt.txt
Volume in drive C is C-Drive
Volume Serial Number is 2482-1E9C

Directory of C:\

02/12/2009 05:10 PM 2,048 ttt.txt

Similarly in Unix, there is a touch command. The touch command updates the access and modification times of each file specified by the parameter or command line argument. If time value is not specified then touch command will use current time. If we specify a file that does not exist, it will create that file with current date time unless –c flag is specified. When –c flag is specified it will not create the file, if it does not exist. Following command shows that.

$ touch -c ttt.txt
$ ls -l ttt.txt
ls: 0653-341 The file ttt.txt does not exist.

Now let us issue same command without using –c flag.

$ touch ttt.txt
$ ls -l ttt.txt
-rw-r–r– 1 b01234 uga 0 Feb 13 17:19 ttt.txt

One Response to “Creating an empty file in Unix and Windows”

  1. EphepeJathy said

    dobry poczatek

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: