Operating System - HP-UX
1826499 Members
1599 Online
109692 Solutions
New Discussion

HOWTO: Create a file exactly x in size

 
SOLVED
Go to solution
Leon Smith
New Member

HOWTO: Create a file exactly x in size

Does anyone know of a simple command create a file exactly a given size.

i.e I want to create a file exactly 1MB in size. This will be used to fillup filesystems for testing.

Similar to SUN's mkfile command used for creating swap space.

Thanks in advance.
2 REPLIES 2
Patrick Wallek
Honored Contributor
Solution

Re: HOWTO: Create a file exactly x in size

Have a look at the 'prealloc' command. I don't remember the exact syntax (that's why they make man pages), but that is the command that you want.
Patrick Wallek
Honored Contributor

Re: HOWTO: Create a file exactly x in size

OK, I found the man pages on HP's docs site:

To create a file called myfile that is 1MB in size:

prealloc myfile 1048576

The size is specified in BYTES.