How to Create a file of Specified Size

So today for...unimportant reasons, I wanted to create a very large file, in the vicinity of 20Gb, without having to actually do any real work to create the file.

I found out in Windows there is a command you can use:
fsutil file createnew [filename] [size]

where:
filename = The filename for the file you are creating
e.g. file.txt or C:\Directory\file.txt

size = size of the file in bytes
e.g. 2147483648 for 2Gb

example:
fsutil file createnew twogigabytefile.txt 2147483648


On Mac OS X 10.5 you can use:
mkfile [size] [filename]

where:
filename = The filename for the file you are creating
e.g. file.txt or
~/directory/file.txt

size = size of the file in bytes
e.g.
512 for 512 bytes, or use the following suffixes b = half kilobytes, k = kilobytes, m = megabytes and g = gigabytes, i.e. 10m for 10 megabytes.

example:
mkfile 2147483648 twogigabytefile.txt
or
mkfile 2g twogigabytefile.txt

2 comments:

Tripp said...

in command prompt?

Leigh McCulloch said...

Yup, in command prompt for Windows, or in Terminal for Mac OS X.

Post a Comment