Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: Prepending to a file

by baku (Scribe)
on Feb 06, 2001 at 20:47 UTC ( [id://56694]=note: print w/replies, xml ) Need Help??


in reply to Re: Prepending to a file
in thread Prepending to a file

The DOS 'copy' command has a -b option to act upon files in 'binary mode,' analogous to Perl's binmode; and depending upon your 'cat' implementation, the fileT and file1 are most likely read through memory in chunks (4K? I think? --something about that being the optimal size for disc transactions...), so that should be a valid way to do this without bring the whole file into RAM. e.g.

[dos-prepend.bat] copy /b prepend+original newfile if errorlevel 1 goto abort copy /y newfile original if errorlevel 1 goto abort del newfile del prepend abort: rem end # vs. [unix-prepend] #!/bin/sh cat prepend original > newfile && ( mv -f newfile original; rm -f prepend )

Of course, dkubb's subroutine is a much better way to cope with this situation.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-25 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found