Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: how to give size to a file at the time of creation

by Tux (Monsignor)
on May 03, 2013 at 08:00 UTC ( #1031842=note: print w/ replies, xml ) Need Help??


in reply to Re: how to give size to a file at the time of creation
in thread how to give size to a file at the time of creation

If your filesystem supports sparse files, you don't need to write it all, one byte will do:

$ rm -f xx ; perl -wE'open$a,">","xx";seek$a,1048575,0;print$a "x"' ; +ls -l xx -rw-rw-rw- 1 merijn users 1048576 May 3 09:59 xx

Enjoy, Have FUN! H.Merijn


Comment on Re^2: how to give size to a file at the time of creation
Download Code
Re^3: how to give size to a file at the time of creation
by Random_Walk (Parson) on May 03, 2013 at 08:59 UTC

    I tried seek first, but I am on a work XP box and it just gave me a small file. Like you said if your OS supports...


    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031842]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2014-07-30 03:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls