"touch" a new file of specified size

From: Douglas Mayne (doug_at_SLACKWARE-1.localnet)
Date: 07/31/05


Date: Sun, 31 Jul 2005 11:19:23 -0600

I know I can quickly create a new file using touch, but is there a quick
way to create a new file of a specific size?

When I use dd as shown below, it takes a long time to create the file
because there is a write operation required for every byte in the file:

dd if=/dev/zero of=some_new_file bs=1024 count=8000000

Is there a way to allocate a file of the same size and not
performing any initialization? I know the resulting allocation might
contain random or junk data, but that's ok.

TIA...



Relevant Pages

  • Re: Initialization of local variables
    ... initialization did not imply save. ... initialized, nonsaved local variables. ... you have to understand it as allowing compilers ... did allocate at least initialized locals statically. ...
    (comp.lang.fortran)
  • Re: help reg ALLOCATABLE arrays with INTENT statement
    ... > end module globmod ... A global variable for such a simple initialization task? ... making sure that the initialization subroutine is ... can it allocate the ...
    (comp.lang.fortran)
  • Re: Creating a logical matrix in a mex-file
    ... Then use mxMalloc to allocate the memory ... Use mxSetData to set the data of the array to the ... This would avoid the initialization of the memory. ...
    (comp.soft-sys.matlab)
  • Re: Should F95 compilers allow allocatable pointers in recursive subroutines?
    ... no such thing as an "allocatable pointer". ... you can use an allocate ... If you think about what initialization means, ... that it is what the standard specifies and thus is not a compiler bug. ...
    (comp.lang.fortran)
  • Re: "touch" a new file of specified size
    ... >> Is there a way to allocate a file of the same size and not ... I am trying some loopback encrypted file system tests. ... The initial contents of the file are not critical because the mkfs step ... does more initialization of the virtual disc structure. ...
    (comp.os.linux.misc)