Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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
Replies are listed 'Best First'.
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 browsing the Monastery: (13)
As of 2015-07-30 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls