coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: truncate feature request - truncate from the start of the file


From: Eric Blake
Subject: Re: truncate feature request - truncate from the start of the file
Date: Thu, 26 Nov 2015 21:17:55 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/26/2015 05:15 PM, Peter Dyson wrote:
> Hi Team,
> 
> It would be great to easily truncate the start of a file and leave a
> portion of the end of the file.

Sadly, the ftruncate(2) system call (which is roughly what truncate(1)
exposes) is only able to change the tail-end length of a file.  There is
no convenient system call that does a one-shot equivalent to a memmove()
of the tail of a file into the head (discarding the head).  But the
existing tools of head or tail already let you do that from one file as
source to another as destination, then move the destination on top of
the source.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]