Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Fastest way of changing the beginning of a txt file.. -- oneliner

by pedrete (Sexton)
on Feb 18, 2019 at 11:13 UTC ( [id://1230082]=note: print w/replies, xml ) Need Help??


in reply to Re: Fastest way of changing the beginning of a txt file.. -- oneliner
in thread Fastest way of changing the beginning of a txt file..

Thanks for your reply...

Your idea would work, but is not exactly what i was trying to do.... i just want move the filesystem pointer from the actual "begginning of file" to a "new beginning of file"...

  • Comment on Re^2: Fastest way of changing the beginning of a txt file.. -- oneliner

Replies are listed 'Best First'.
Re^3: Fastest way of changing the beginning of a txt file.. -- oneliner
by BrowserUk (Patriarch) on Feb 18, 2019 at 12:28 UTC
    i just want move the filesystem pointer from the actual "begginning of file" to a "new beginning of file"...

    No filesystem (AFAIK) provides that facility.

    In theory, it could be done (after a fashion) using low-level IO primitives, but only to the nearest block boundary -- which might be modulus 512, 4096 or some other power of 2 depending upon the device the file is located on -- which isn't very useful.

    It is possible to truncate the end of a file on most file systems; and again in theory, it might be somewhat quicker to copy the rest of the file over the removed portion in situ, then truncate the end. But it is easy to get this wrong and there is no guarentee it will be quicker on any given device or day.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit
Re^3: Fastest way of changing the beginning of a txt file.. -- oneliner
by Discipulus (Canon) on Feb 18, 2019 at 11:17 UTC
    Hello,

    you can use seek but it seeks in bytes and you anyway have to scan the file in advance to track the position of wanted first line so I see no point in this (unless you alredy have it recorderd somehow).

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

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

    No recent polls found